Create migrations with EF Core in Xamarin Android project

ef-migrations entity-framework-core xamarin.android

Question

I tried to use EFCore with SQLite in a Xamarin.Android project. I also added the package Microsoft.EntityFrameworkCore.Tools. When I try to create database migrations I get various errors.

When running dotnet ef migrations add migrationname on the command line I get the error

No executable found matching command "dotnet-ef"

When running Add-Migration migrationname in Package Manager Console I get error

Startup project 'MyProject' targets framework 'MonoAndroid'. The Entity Framework Core Package Manager Console Tools don't support this framework.

Is there some way around this? Do I have to use EF6 instead of

1
5
2/8/2018 3:54:01 PM

Accepted Answer

The guidance for unsupported frameworks is to move your DbContext code into a .NET Standard class library and use a dummy .NET Core console app with the tools.

cd MyDbContextProject
dotnet ef migrations add MyMigration --startup-project ..\MyDummyProject
2
2/8/2018 5:48:30 PM


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