Versioning in Entity Framework ( EF)
Most of the people feels Entity Framework versioning headache. This is due to differences in what EF can support depending on what version of the .NET run time your app is targeting. In today’s blog, I will cover simple errors and the versioning challenges and solutions related to it.
Most of the people struggles with errors like,
Unable to find version ‘4.4.0.0’ of package ‘EntityFramework’.
This is due to differences in what EF can support depending on what version of the .NET run time your app is targeting.
- If you are targeting .NET 4 and install EF 5, the assembly version will be 4.4
- If you are targeting .NET 4.5 and install EF 5, the assembly version will be 5.0
This is because things such as DBGeography only can work if .NET 4.5 is present.
We just need to install EF 5 proper and the NuGet package will figure this out and give you the proper version.
One point to be very clear about : There is nothing like Entity Framework 4.4”
The 4.4 comes from assembly version of EntityFramework dll when you install EntityFramework 5.0 into the project that targets .Net framework 4.0. This is merely the side effect of how the assembly loads and binds to assemblies, and in no way reflects the version of the product.
Here is the simple code that prints out version information about the EntityFramework assembly
var assembly = type(DBContext).Assembly;
var name = assembly.GetName();
var info = FileVersionInfo.GetVersionInfo(assembly.Location);
Console.WriteLine(“AssemblyVersion: {0}”, name.Version);
Console.WriteLine(“Product Version: {0}”, info.ProductVersion);
When we run above code on application targeting
On .Net Framework 4.5, we get the following output:
- Assembly Version: 5.0.0.0
- Product Version: 5.0.0.net45
On .Net Framework 4.0, we get the following output:
- Assembly Version: 4.4.0.0
- Product Version: 5.0.0.net40
As you can see, the product version in both case is 5.0
So, always refer to the product as EntityFramework 5.0, and if you think the information is relevant, also let people know what version of the .Net Framework you are targeting.
http://www.anarsolutions.com/versioning-entity-framework-ef/?utm_source=blogger.com
No comments:
Post a Comment