我是 MVC 的新手,所以请忍受一点迷失方向。我有一个包含以下项目的 .NET 4.5 解决方案:
- Parkalot.Entity(包含实体类)
- Parkalot.Database(包含数据上下文类)
- Parkalot.Mvc4AspxClient(网络客户端)
所有项目都使用 NuGet 配置了 EntityFramework 5,并且所有项目都面向 .NET 4.5。全部设置为任何 CPU。64 位 Windows 8 Pro 上的 Visual Studio 2013 Ultimate Preview(没关系)。
如果我尝试使用数据上下文从 Web 客户端的 Global.asax 访问数据库,它可以正常工作,因此直到 Web 客户端都没有问题。
添加控制器时,只要我选择[Empty MVC Controller]
模板,它就可以正常工作。当我尝试添加具有模板类型的控制器[MVC Controller with read/write actions and views, using Entity Framework]
并选择 Parkalot.Entity.Tenant 作为模型类并选择 Parkalot.Database.Context 作为数据上下文类时,我收到以下错误:
Unable to retrieve metadata for 'Parkalot.Entity.Tenant'. Could not load file or assembly
'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
one of its dependencies. The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
如果它是相关的,我还会收到以下编译时警告:
C:\...\Microsoft.Common.CurrentVersion.targets(1613,5): warning MSB3247:
Found conflicts between different versions of the same dependent assembly.
Please add the following binding redirects to the "runtime" node in your
application configuration file:
- Parkalot.Mvc4AspxClient ->
C:\...Parkalot.Mvc4AspxClient\bin\Parkalot.Mvc4AspxClient.dll
该解决方案最初是在 VS2010 中创建的,然后升级到 VS 2013 和 .NET 4.5。我想知道这是否是原因,但仍然不知道如何解决它。
编辑:按照错误指示搜索版本 4.4.0.0 时,我发现以下内容!
C:\...\Parkalot.WinFormsClient\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.WinFormsClient\Visual Studio\app.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:\...\Parkalot.Library\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.Library\Visual Studio\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:\...\Parkalot.Entity\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.Entity\Visual Studio\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:\...\Parkalot.Database\App.config(8):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.Business\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.Business\Visual Studio\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:\...\Parkalot.Configuration\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.Test\App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.WebFormsClient\Web.config(9):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:\...\Parkalot.Mvc4AspxClient\Web.config(9):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:\...\Parkalot.Mvc4RazorClient\Web.config(9):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />