How to run a migration in UWP using ef core 1

旧时模样 提交于 2019-12-10 16:29:51

问题


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:


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



来源:https://stackoverflow.com/questions/36044416/how-to-run-a-migration-in-uwp-using-ef-core-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!