Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade from entity framework 4 to EF6?

I want to create an EntityDataModel with Entity Framework 6 but every time I try I get this error:

Your project references an older version of Entity Framework.

enter image description here

I'm using Visual Studio 2013 and my project is Asp.net 4.5.1 web forms project. this is my web.config file, I deleted some sections of this file in order to solve the problem but all in vain.

<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please   visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

The following attributes can be set on the <httpRuntime> tag.
  <system.Web>
    <httpRuntime targetFramework="4.5.1" />
  </system.Web>
-->
<system.web>
<compilation debug="true" targetFramework="4.5.1">
  <assemblies/>
</compilation>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
</system.web>
<system.codedom>
<compilers>
  <!--<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
  -->
</compilers>
</system.codedom>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<connectionStrings>
<add name="tebimir_db_tebimEntities" connectionString="metadata=res://*/DataAccessLayer.tebimir_db_tebim.csdl|res://*/DataAccessLayer.tebimir_db_tebim.ssdl|res://*/DataAccessLayer.tebimir_db_tebim.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tebim.ir,9993;initial catalog=tebimir_db_tebim;persist security info=True;user id=tebimir_dbadmin;password=qwerty*2607548;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
 <add name="tebimir_db_tebimEntities_plain" connectionString="data source=185.94.97.58,9993;initial catalog=tebimir_db_tebim;persist security info=True;user id=tebimir_dbadmin;password=qwerty*2607548;"/>
 </connectionStrings>
 <system.webServer>
 <defaultDocument>
  <files>
    <clear/>
    <add value="index.aspx"/>
  </files>
</defaultDocument>
 <validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="mssqllocaldb"/>
   </parameters>
  </defaultConnectionFactory>
  <providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
   </providers>
  </entityFramework>
 </configuration>
like image 605
Ali.Rashidi Avatar asked May 28 '16 10:05

Ali.Rashidi


2 Answers

Try updating Entity Framework using NuGet Before adding the model, follow these steps

  1. Right click on your project in VS Solution explorer and select 'Manage NuGet packages'

  2. Select EntityFramework ad Click update.

  3. Now add the Entity Data Model.

like image 127
Mihir Kale Avatar answered Sep 18 '22 11:09

Mihir Kale


I suggest you to uninstall all the entity framework packages and reinstall it from nuget packages. I hope it will help you.

For more information you can use this link.

like image 22
Tuks Avatar answered Sep 18 '22 11:09

Tuks