10

I am using Visual Studio 2022 with.Net 6.0, I installed Entity Framework 6.4.4 after adding it when I create an Entity Framework model. I am getting a Popup message saying that.

The project's target framework does not contain Entity Framework runtime assemblies. Please review the target framework information on the project's property page.

Can somebody tell us how to solve that problem? enter image description here

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188
Nishant Bangera
  • 176
  • 1
  • 1
  • 8
  • 4
    You are using `Entity Framework 6.4.4` you should be using `Entity Framework Core 6.0.1` – Rand Random Jan 03 '22 at 12:04
  • Sir, I used that too but it's not working keep saying with the same popup message. (Microsoft.EntityFrameworkCore 6.0.1) – Nishant Bangera Jan 04 '22 at 05:27
  • 1
    No, you are not, because Entity Framework Core doesn’t have the ability to add Entity Model, the way you do it. Entity Framework Core only supports code first approach. eg. https://learn.microsoft.com/en-us/ef/core/modeling/ – Rand Random Jan 04 '22 at 06:54
  • Sir can you tell me step by step procedure 1. New Projects-->Console Application-->install Package from NugetPackage Manager 2. Entity Framework anyone from this v(6.4.4),v(6.1.3), core 3. Solution explorer select project right click add item 4. New Item data-->Ado.net Entity Data Model – Nishant Bangera Jan 05 '22 at 06:17
  • Can you tell me What that popup massage suggests? – Nishant Bangera Jan 05 '22 at 06:18
  • Thank you, sir, I got the Answer We have to use .net below 5.0v – Nishant Bangera Jan 05 '22 at 07:32
  • This is a common cause of confusion. The last version of .Net Framework is 4.8 - this is what you should be using with Entity Framework. After that .Net Core 1.0 to 3.2 and .Net 5 & 6 (The "Core" got dropped in an effort to make it seem like all use "Entity Framework Core". That "Core" bit is really important and often gets overlooked (it's the same for ASP.Net and ASP.Net Core) – phuzi Jan 05 '22 at 09:45
  • 3
    Step 3 and 4 should NOT be used at all, when you want to use .net 6, because as I said it prior it is unsupported, as you figured it out yourself, if you want to use this, for whatever reasoning, you will have to use .net framework 4.x and not .net 5.x or .net 6.x. BUT I would strongly recommend to not go this path, use .net 6.x and use Entity Framework Core 6.0.1, and write the models yourself in the so called `code first` approach. DO NOT USE THE USER INTERFACE to create the model, WRITE THE CODE YOURSELF. – Rand Random Jan 05 '22 at 10:41
  • Im sure the database boys absolutely LOVE this one!! – MagicWand Feb 17 '22 at 17:01

3 Answers3

3

You can install .Net Framework 4.8.

.Net Core 1 - 3.2 & .Net 5 & 6 has no Entity Framework Data Model available with EF Core.

You want to use EF 6 (not Core) and Data Model you have to use .Net Framework 4.8 or lower than that.

phuzi
  • 12,078
  • 3
  • 26
  • 50
Nishant Bangera
  • 176
  • 1
  • 1
  • 8
  • Entity Framework Visual Designer https://msawczyn.github.io/EFDesigner/index.html Entity Framework Visual Editor Entity Framework visual editor for EF6, EFCore and beyond. https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner2022#:~:text=This%20Visual%20Studio%202022%20extension,visual%20design%20of%20persistent%20classes. – Stewart Dec 07 '22 at 23:34
2

Ensure you have Target Framework as show.

enter image description here

2

Try this to generate/update entire DbContext and models:

Scaffold-DbContext -Connection "Server=(local);Database=DefenderRRCart;Integrated Security=True;Trusted_Connection=True;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir RRStoreContext.Models -context RRStoreContext -Project RR.DataAccess -force

See this post for more info. https://stackoverflow.com/a/41413291/4588756

Hossein
  • 3,083
  • 3
  • 16
  • 33