I need to turn off alphabetic ordering in code first.
Here is my class simplified
public class Person
{
[Key,Column("PersonId")]
public int Id { get; set; }
[MaxLength(50)]
public string PersonName{ get; set; }
public DateTime? JoinDate{ get; set; }
public int? Gender{ get; set; }
}
and when I run the commands to generate the database
dnx ef migrations add InitialMigration
dnx ef database update
The database columns apart from the primary key generates in alphabetic order when I view it in design mode in SQL Server 2012.
How do I force it to create the columns in sequential order as it appears in the class.
I had a look on github and could only find this issue which doesn't explain how to turn it off.
There is no first-class support for this behavior in EF7 migrations. You can workaround this by explicitly specifying SQL your migration operations.
That means instead of using the "CreateTable" method in your migrations, you need to explicitly write the SQL.
migrationBuilder.Sql("CREATE TABLE Person ...");