Entity Framework Migrations
Overview
- Create a Modal class
public class Blog
{
public int Id { get; set; }
public string Name { get; set; }
}
- create migration name InitialCreate
dotnet ef migrations add InitialCreate
- Create the database
dotnet ef database update
- Update the model class
public class Blog
{
public int Id { get; set; }
public string Name { get; set; }
// add new property
public DateTime CreatedTimestamp { get; set; }
}
- Create a new migration
dotnet ef migrations add AddCreatedTimestamp
- Update the database
dotnet ef database update
Remove Migration
dotnet ef migrations remove
List Migrations
dotnet ef migrations list