Cannot use Entity Framework in .NET standard 2 project

11,597

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

Share:
11,597
Paul
Author by

Paul

I work for an Energy Consultancy company - STC Energy in Kent, UK I have very varied skill set, Delphi, .NET, Silverlight, SQL, Pascal, MVC, Kendo, Javascript, etc

Updated on June 06, 2022

Comments

  • Paul
    Paul almost 2 years

    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

    • Panagiotis Kanavos
      Panagiotis Kanavos about 6 years
      It's not. EF 6 came years before .NET Standard 2.0. The .NET Standard compatilbe version is EF Core.
    • Paul
      Paul about 6 years
      Is it not possible to have a visual model designer for EF Core?
  • Paul
    Paul about 6 years
    When I try to use this I get another error Currently only .NET Framework and .NET Core 2.0 projects are supported - TargetFrameworkMoniker: .NETStandard,Version=v2.0
  • David Browne - Microsoft
    David Browne - Microsoft about 6 years
    The tooling for EF doesn't fully work with a project that targets only .NET Standard. But the runtime does. Try running the tooling in a console app targeting .NET core and moving the generated code artifacts into your .NET Standard class library.