Reputation: 61
Startup project 'EFGetStartedUWP' is a Universal Windows Platform app. This version of the Entity Framework Core Package Manager Console Tools doesn't support this type of project. For more information on using the EF Core Tools with UWP projects, see https://go.microsoft.com/fwlink/?linkid=858496
I'm trying to connect SQLite Database to a basic UWP app for the sake of learning but when I try migration. It just keep giving me the above error. I've searched quite a lot on the internet but didn't get the appropriate answer. The Microsoft documentation is of no use in this scenario. Also I've installed Microsoft.EntityFrameworkCore.Sqlite & Microsoft.EntityFrameworkCore.Tools.
If anyone can suggest any other way to connect SQLite database to UWP that'll be very useful too as I'm quite new to C# and I've a university project to do on a UWP app.
Upvotes: 3
Views: 2330
Reputation: 280
I've just stepped on a similar issue, and I've been lucky enough to solve it. To start with, I found these links very useful: Entity Framework Core tools reference - .NET Core CLI - Other target frameworks and Common options.
In my case, my solution ended up with a configuration like this:
Have into account that (at the time of writing) UWP doesn't support .NET Standard 2.1. It supports .NET Standard 2.0 from version 10.0.16299. This means the (Universal Windows) application project can't reference a .NET Standard 2.1 project (e.g. .NET 5.0, .NET Core 3.0, Mono 6.4, etc.), so the class library project CAN'T be .NET 2.1, .NET 5.0, etc. The opposite is not true: a .NET 5.0 or .NET 6.0 project can reference a .NET Standard 2.0 project, so the dummy console app project can be .NET 6.0.
Steps to add a migration:
Microsoft.EntityFrameworkCore.Sqlite
). Do not install the most recent version but the last that depends on .NET Standard 2.0, which is 3.1.21
at the time of writing.Microsoft.EntityFrameworkCore.Design
. For compatibility purposes, install the same version as the version chosen in the previous step (e.g. 3.1.21
).Add > Project Reference...
, and tick the class library project.)cmd
in the address bar to open the command prompt in that folder).-p
signals the target project while -s
indicates the startup project):?> dotnet ef migrations add #MigrationName -s #DummyConsoleAppProject -p #ClassLibraryProject
Upvotes: 5
Reputation: 187
This looks to be a known issue from here: https://github.com/aspnet/EntityFrameworkCore/issues/9666
Using EFCore with UWP is a bit finicky.
So, add a new project to your solution -> select .net core console app -> create DBContext and your models there -> run the "Add-Migration" command and reference it back to your main project.
That should get rid of that error and let you use migrations with UWP.
Upvotes: 2