Entity Framework 4.1, can't find Load () method?

Ok, I'm going to smash the keyboard with a hammer about this. I decided to play with EF this weekend, and I started the project in 4.0. I will find out that 4.1 is missing, so I download and install the package.

Imagine my surprise when I use the Load () method in dbExtensions and cannot find it. So I add a link to the EntityFramework binary created by the installer, removes the System.Data.Entity link from the project, rebuilds, and it says

"The type 'System.Data.Objects.ObjectContext' is defined in the assembly, which is not a reference. You must add the link to the assembly 'System.Data.Entity, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089."

I tried to restore my model, I tried to delete things, I tried to directly refer to 4.1 via usings. Nothing works.

I am clearly missing something basic. How the hell am I going to tell a visual studio about using frame 4.1?

+6
source share
5 answers

I managed to find the missing .Load () function by adding the following:

using System.Data.Entity; 
+27
source

Entity Framework 4.1 is not a standalone version. It still needs Entity Framework 4.0 and its assembly, so yu cannot remove System.Data.Entity.dll from your links. In addition, EFv4.1 is mainly associated with the new DbContext API, so if you are not going to switch from Entity objects to POCOs and DbContext , you will not get any benefits by referring to EntityFramework.dll (except for the strongly typed Include on IQueryable ).

+4
source

Add the link to System.Data.Entity.dll from:

GAC (.Net tab in add links dialog)

or

C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.Entity.dll

+2
source

I have the same problem and still do not know the reason.

Finally, I use an alternative solution:

 var query = from d ... query.Load(); 

or

 (DbSet)context.myentity).Load(); 

Give it a try.

+1
source

Ladislav's message is accurate. To add a bit more detail, this ADO.Net team blog post explains how to properly replace code generation in an EF 4.0 project with EF 4.1.

However, I have a similar problem after upgrading to 4.1 and using DbContext (including some other features). I also don't have a .Load () method. I think you were in the same place as me before you started (unnecessarily) messing with links.

Check out the link above, let me know if this helps, and if you find a solution for the missing .Load () function, let us know.

0
source

Source: https://habr.com/ru/post/886578/


All Articles