Davood
Davood

Reputation: 5635

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?

Upvotes: 7

Views: 8443

Answers (1)

Shyju
Shyju

Reputation: 218722

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.

Upvotes: 10

Related Questions