In MVC architecture, we creates some entities like user,role etc.
For example:
User entity:
public class User
{
[Key]
public int ID
{
get;
set;
}
[MaxLength(100)]
public string UID
{
get;
set;
}
[MaxLength(100)]
public string FirstName
{
get;
set;
}
[MaxLength(100)]
public string LastName
{
get;
set;
}
[MaxLength(100)]
public string DisplayName
{
get;
set;
}
[MaxLength(100)]
public string Identity
{
get;
set;
}
[MaxLength(100)]
public string Email
{
get;
set;
}
[DataType(DataType.Password)]
[MaxLength(100)]
public string Password
{
get;
set;
}
[MaxLength(100)]
public bool IsActive
{
get;
set;
}
}So, all these are the columns in user datatable. if you want another column called Phoneno, then add public string Phone { get; set; } in above set.
So then if you run the solution, it throws build error as,
"Additional information: The model backing the 'EFDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269)."
At this point we have to do "Code first migration" using some command
Steps for Code First Migration:
Visual Studio13->Tools->NuGetPackageManager-> select the entity folder-> type Enable-Migrations->next type Add-Migration-> after completing two command succesfully, finally type "Update-Database". Finish then automatically the additional column will be added to user datatable.
