How to run a migration in UWP using ef core 1

2019-06-25 12:19发布

I don't know how I have run the migration in EntityFramework.Core(v7.0.0-rc1-final) using EntityFramework.Commands(also v7.0.0-rc1-final). When I add the migration (Add-Migration) so migration creates. Then, when I enter the Update-Database, so the PM console returns:

Update-Database should not be used with Universal Windows apps. Instead, call DbContext. Database. Migrate () at runtime.

But the Context.Database does not contain method Migrate(). So this command cannot be specified. It seems to me that this is a bug.

1条回答
不美不萌又怎样
2楼-- · 2019-06-25 13:09

In RC1, make sure you have using Microsoft.Data.Entity; in the document. Migrate() is an extension method that is available when you install a relational provider, such as EntityFramework.Sqlite.

        using (var db = new BloggingContext())
        {
            db.Database.Migrate();
        }

See https://docs.efproject.net/en/latest/platforms/uwp/getting-started.html

查看更多
登录 后发表回答