Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using entity framework code first to created database.
i want to add a new field(description) to an exist table after it's [Name] column.

My steps:

1. Exist Table ( Blog ) looks like:
[ID, Name, Url]

2. I want to add [Description] to Blog table after [Name] column, it should to be:
[ID, Name, Description, Url]

3. Entity framework model class of Blog:
C#
 public partial class Blog
{
  [Key]
  public int ID {get; set;}

  public string Name {get; set;}

  public string Url {get; set;}
}


4. i add new attribute [Description] in Blog model:

C#
<pre lang="c#">
 public partial class Blog
{
  [Key]
  public int ID {get; set;}

  public string Name {get; set;}

  // new attribute, which i want to add this column in table after Name
  public string Description {get; set;}

  public string Url {get; set;}
}


5. add migration:

Add-Migration AddDescriptionForBlog

6. update database:

Update-Database

7. look at table, it place [Description] field at last column.

[ID, Name, Url, Description]

My question:

how can i place [Description] in filed after Name column in the table?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900