4

How do we use data migrations in asp.net core? I'v tried looking through the asp.net core documentation but couldn't find anything.

This was the code for asp.net 4:

internal sealed class Configuration : DbMigrationsConfiguration<ApplicationDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = true;
    }

    protected override void Seed(ApplicationDbContext context)
    {
        base.Seed(context);

        //Add stuff to database

        context.SaveChanges();
    }
}

What is the equivalent in asp.net core?

Martin Dawson
  • 7,455
  • 6
  • 49
  • 92
  • read: https://docs.asp.net/en/latest/data/entity-framework-6.html, and https://docs.efproject.net/en/latest/platforms/aspnetcore/ it may help. – M.Hassan Jul 20 '16 at 21:58
  • Here's the answer I was looking for entity framework 7: http://stackoverflow.com/questions/34536021/seed-initial-data-in-entity-framework-7-rc-1-and-asp-net-mvc-6 – Martin Dawson Jul 21 '16 at 13:50

1 Answers1

2

If you're using EF core: https://docs.efproject.net/en/latest/miscellaneous/cli/dotnet.html

If you're using EF 6.x, you may need a community one: https://github.com/mrahhal/Migrator.EF6

Takahiro
  • 1,222
  • 10
  • 11