EntityFramwork Power Tools在生成视图时出错 [英] EntityFramwork Power Tools error while generating views

查看:233
本文介绍了EntityFramwork Power Tools在生成视图时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用EntityFramework Power Tools(0.9 beta)的生成视图函数时,生成失败,并在输出窗口中收到以下错误:


When trying to use the Generate Views function of EntityFramework Power Tools (0.9 beta), the generation fails and I get the following error at the Output window:

System.Reflection.TargetInvocationException: 
Exception has been thrown by    the target of an invocation. --->
System.TypeLoadException: Could not load type 
'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 
'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at MyProject.Entities.Models.MyDbContext.OnModelCreating(DbModelBuilder modelBuilder)

我的上下文继承从 IdentityDbContext ,当电源工具试图为Identity模型生成视图时,似乎导致此问题。

My context inherits from IdentityDbContext, what seems to cause this issue when the power tools tries to generate views for the Identity models.

只有在尝试生成视图时,才会发生这种情况。解决方案本身构建并运行没有任何错误。

This happens only wen trying to generate the views. The solution itself builds and runs without any errors.

为了简化和隔离这个问题,我在vs 2013中创建了一个新的网站项目,身份和实体框架6.0以及一代工程罚款。将包更新到Identity 2.2.1和EntityFramework 6.1.3会导致错误和生成失败。

To simplify and isolate this problem I've created a new website project in vs 2013 with identity and entity framework 6.0 and the generation works fine. updating the packages to Identity 2.2.1 and EntityFramework 6.1.3 causes the error and the generation fails.

我已经检查了项目引用,它看起来像是正确的Entityframework版本被引用。

I've checked the project references and it looks like the right Entityframework version is referenced.

我的.csproj引用:

My .csproj references:

<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
  <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.Identity.Core">
  <HintPath>..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.Identity.EntityFramework">
  <HintPath>..\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.1\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll</HintPath>
</Reference>

似乎电动工具坚持使用没有$ code的6.0版本> System.ComponentModel.DataAnnotations.Schema.IndexAttribute 类型,因为它只在6.1版本中引入,而是添加到最新的Identity模型中以限制唯一的UserName。

Seems like the Power tools is insisting of using the 6.0 version that dont have the System.ComponentModel.DataAnnotations.Schema.IndexAttribute type yet, since it has only introduced at the 6.1 version, but it was added to the latest Identity models to restrict unique UserName.

任何想法?

推荐答案

结果Power工具正在使用Visual Studio IDE版本的EntityFramework,而不是项目中引用的。在我的情况下是6.0.2。安装 Visual Studio 2013 Update 5(2013.5)RTM on我的机器解决了这个问题,现在使用了最新的EntityFramework 6.1.3。

Turns out the the Power tools is using the Visual Studio IDE version of EntityFramework, and not the referenced one from the project. In my case it was 6.0.2. Installing Visual Studio 2013 Update 5 (2013.5) RTM on my machine solved the problem, and the latest EntityFramework 6.1.3 is now used.

这篇关于EntityFramwork Power Tools在生成视图时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆