Entity Framework for netcoreapp 3.1

leo del ciello 66 Reputation points
2022-08-26T11:05:03.387+00:00

I want to write a simple Desktop WinForms application using Entity Framework to access Data .

My project file's contante is as follows :

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">  
  
  <PropertyGroup>  
    <OutputType>WinExe</OutputType>  
    <TargetFramework>netcoreapp3.1</TargetFramework>  
    <UseWindowsForms>true</UseWindowsForms>  
  </PropertyGroup>  
  
</Project>  

I tried installing from Nuget every possible version of EF but noone is compatible with netcoreapp 3.1

What should I do to use EF ? and moreover, is it possible to use it on netcore 3.1 ?

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
697 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Jack J Jun 24,286 Reputation points Microsoft Vendor
    2022-08-29T04:44:33.28+00:00

    @leo del ciello , Welcome to Microsoft Q&A, We need to make sure that we used .net 6.0 version when we want to use EF core in .NET Core app.

    Please refer to the following steps to use ef core in winform app.

    First. Please install .NET 6.0 from the following link:

    https://dotnet.microsoft.com/en-us/download/dotnet/6.0

    Second. Please change your project file into the following:

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">  
      
      <PropertyGroup>  
        <OutputType>WinExe</OutputType>  
        <TargetFramework>net6.0-windows</TargetFramework>  
        <UseWindowsForms>true</UseWindowsForms>  
      </PropertyGroup>  
      
    </Project>  
    

    Third, Please install the latest version nuget package like the following:

    Microsoft.EntityFrameworkCore  
    

    Finally, you could use ef core in your winform project.

    Best regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Frabrizio contin 1 Reputation point
    2022-08-29T16:28:19.237+00:00

    Always do you select the same nuget package than your version framework.
    In my case i have net 5.0 framework and i selected only nuget library in 5.X.X (RED)
    In your case you must selected only 3.x.x Or update your framework to 7.XXX and install nuget in 7.XX (Green)

    235841-image.png


  3. leo del ciello 66 Reputation points
    2022-08-31T19:51:28.42+00:00

    For anyone who might be interested : I just discovered VS 2019 Community (which I was using) does not support .Net 6.0.

    I installed VS 2022 Community and now I can use Entity Framework Core 7.0.

    0 comments No comments