Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i use Entity Framework 4.1 in Visual Studio 2012?

I have a web application on a web farm and i use .NET 4 and entity data model 4.1.

when i started working on this web application i used visual studio 2010, and today i have uninstalled it and installed new version (Visual Studio 2012).

Due to some reasons, i have deleted my ado.net entity data model to recreate it, but i
pay attention that visual studio 2012 use entity framework 5 not 4.1. I have updated it but in old model i can context constructor to change my connection string but in this new model have no constructor, is that true?

I have installed EF 4.1 but it doesn't works and I've added version 5 to my project. Background info: my web application is on a shared host and i can not update it to EF 5.

How can i use entity framework 4.1 in visual studio 2012 ? is that possible? if yes, how?

like image 780
motevalizadeh Avatar asked Oct 23 '12 12:10

motevalizadeh


People also ask

How can I change Entity Framework 6 to 5?

In this situation you can upgrade to EF5 using the following steps: Select Tools -> Library Package Manager -> Package Manager Console. Run Install-Package EntityFramework -version 5.0. 0.


1 Answers

Remove Existing (Entity framework 5)

  1. Remove the existing reference (to Entity framework 5) under the References section in your Project in Solution explorer.

  2. Remove the corresponding entry from your packages.config file. If you open the packages.config file, you will see an xml structure and you will see an element with id EntityFramework with version attribute value as 5.0.0. Remove that line( that package element).

Add Again (Entity framework 4.1)

Now go to the package manager window(View->Other Windows -> Package Manager Console) and execute the following command there.

Install-Package EntityFramework -Version 4.1.10331.0

This will download EF 4.1 to your project and you will see the success message like below.

enter image description here

Reference : http://nuget.org/packages/EntityFramework/4.1.10331.0

Always keep in mind that there are a lot of improvements made in EF 5. So consider to consume all those as possible as you can.

like image 176
Shyju Avatar answered Oct 26 '22 07:10

Shyju