Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order the Columns, while creating DB by Entity Framework 4.1. with fluent API

I want have an order of my database table columns after creating DB by entity framework 4.1. in the following way:

1) PK 2) all foreign key columns 3) all complex types columns 4) all Other Columns

The problem is that it is no possibility to set the Order for foreign key's by fluent API, like for example HasColumnOrder for primitive properties.(all foreign key columns are the last columns)

Are there some ideas?

Thanks

Chris

like image 397
user805255 Avatar asked Oct 11 '22 07:10

user805255


1 Answers

I know this is an old thread, but I thought I would actually answer it. I agree, the column order in the DB makes no difference. Except for when you are in the DB searching on data, then it can be useful to have the logical/useful fields first.

The answer is with the .HasColumnOrder(x) method. Just put in a zero-based number of what order you want the field to be in. See an example here: http://hanksnh.wordpress.com/2011/04/08/inheritance-with-entity-framework-4-1/

like image 192
Grandizer Avatar answered Oct 12 '22 21:10

Grandizer