jueves, 23 de febrero de 2017

Entity Framework - How to add a new table to an existing database when using code first migrations

Entity Framework 
How to add a new table to an existing database when using code first migrations


Just create your new table as a model and add its entry in your DBContext class:


public class MyContext : DbContext, IDisposable
{
    public DbSet<MyModel1> Model1 { get; set; }
    public DbSet<MyModel2> Model2 { get; set; }

    public DbSet<MyNewModel> MyNewModels { get; set; }


Then Run the Add-migrations and Update-Database commands from the Package manager console

No hay comentarios.:

Publicar un comentario