How to run a migration in UWP using ef core 1

entity-framework-core win-universal-app

Question

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
4
3/16/2016 6:46:17 PM

Accepted Answer

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

6
3/17/2016 2:45:46 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow