Mathias Rönnlund
Mathias Rönnlund

Reputation: 4817

Create migrations with EF Core in Xamarin Android project

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

Upvotes: 12

Views: 5802

Answers (1)

bricelam
bricelam

Reputation: 30365

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

Upvotes: 7

Related Questions