简体   繁体   中英

Asp.net core code first database migrations

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM