我的小代码第一个项目中的实体框架版本错误

时间:2012-07-12 00:32:02

标签: asp.net-mvc-3 c#-4.0 entity-framework-4.1 ef-code-first entity-framework-4.3

我正在编写一个小型测试项目,以便首先了解EF代码。不幸的是,当我尝试编译时,我收到以下错误:

Assembly 'Backend, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses   
'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'  
which has a higher version than referenced assembly 'EntityFramework, Version=4.1.0.0,  
Culture=neutral, PublicKeyToken=b77a5c561934e089'   c:\Users\Kevin\Documents\Visual   
Studio 2010\Projects\CFTest\Backend\bin\Debug\Backend.dll   CFTest

出于某种原因,存在版本冲突,但我不知道如何解决它。

编辑:我的App.config:

<?xml version="1.0" encoding="utf-8"?>
<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=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

2 个答案:

答案 0 :(得分:2)

我的后端项目有一个版本的EF,而我的MVC项目默认带有另一个版本。解决。

答案 1 :(得分:0)

它与您的项目正在使用的.NET框架版本以及编译EF dll的.NET Framework版本冲突。如果您转到项目的添加引用窗口,列表应该说每个DLL使用的.NET Framework版本。将项目目标更改为使用该版本。

相关问题