Paul
Paul

Reputation: 3253

Cannot use Entity Framework in .NET standard 2 project

How can I use Entity Framework, or something similar within a .NET Standard project?

It appears as though EF is not supported in .NET Standard 2 which is really annoying!

So I have tried using Microsoft.EntityFrameworkCore.SqlServer and icrosoft.EntityFrameworkCore.SqlServer.Design

Whist I can install these packages, I cannot then add a model

I get the error

---------------------------
Microsoft Visual Studio
---------------------------
The project's target framework does not contain Entity Framework runtime assemblies. Please review the target framework information in the project's property page.
---------------------------
OK   
---------------------------

How can I get around this?

I am seriously thinking to get rid of .NET Standard out of all my projects but that is a bit drastic!

Paul

Upvotes: 3

Views: 13005

Answers (2)

Giovanny Farto M.
Giovanny Farto M.

Reputation: 1588

Change the EF version. There are some versions of EF that work with NetStandard2.0 but other (recently ones) usually don't.

For example with the version 6: enter image description here

And with version 5, you can use it in a Standard project:

enter image description here

Upvotes: 0

Panagiotis Kanavos
Panagiotis Kanavos

Reputation: 131180

It looks like the actual question is "How can I create models and reverse engineer a database using EF Core like I could with EF 6" ?

The tooling is separate from the NuGet package. Visual Studio 2017 doesn't include modelling or reverse engineer tools for EF Core. Those are available through EF Core Power Tools an open source addon. You can find the code and documentation here

Upvotes: 7

Related Questions