【问题标题】:Entity Framework IndexAttribute error when Using MySql with ASP.Net MVC将 MySql 与 ASP.Net MVC 一起使用时出现实体框架 IndexAttribute 错误
【发布时间】:2017-06-25 13:29:13
【问题描述】:

我希望我的 mvc 应用程序连接到 MySQL 数据库,我从早上开始执行了以下步骤,但缺少一些东西。

  1. .Net 安装了MySQL 连接器(连接器ODBC 5.3)
  2. 已安装(MySQL 用于 Visual Studio 1.2.6)
  3. 按照教程进行 https://docs.microsoft.com/en-us/aspnet/identity/overview/getting-started/aspnet-identity-using-mysql-storage-with-an-entityframework-mysql-provider#configure-entityframework-to-work-with-a-mysql-database
    • nuget 安装了 entityframework 6.1.3

现在当我运行网站并尝试注册时,它崩溃了

无法加载类型 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' 来自 程序集'EntityFramework,版本=6.0.0.0

我的 .csproj 文件包含

<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
  <Private>True</Private>
  <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
  <Private>True</Private>
  <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="MySql.Data">
  <HintPath>..\packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="MySql.Data.Entity, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL" />
<Reference Include="MySql.Data.Entity.EF6">
  <HintPath>..\packages\MySql.Data.Entity.6.9.9\lib\net45\MySql.Data.Entity.EF6.dll</HintPath>
</Reference>

我的应用参考包括:

  • 实体框架
  • EntityFramework.SqlServer
  • Microsoft.AspNet.Identity.EntityFramework
  • MySql.Data
  • MySql.Data.Entity.EF6

我也加了

  • MySql.Data.Entity 来自(MySQL for Visual Studio 1.2.6)中的程序集

我是 MVC 和 MySQL 的新手。所以,对可能出现的问题没有清晰的认识。

更新 有人在另一篇文章中建议我需要将其从 gacutil 中删除。现在 gacutil 说我需要管理员权限才能删除已经拥有的程序集。有解决方法吗?这是正确的解决方案吗?

【问题讨论】:

标签: mysql asp.net asp.net-mvc entity-framework gacutil


【解决方案1】:

嗯,我尝试的更新是正确的。所以问题是我在 gac 中有一个版本为 6.0.0.0 的重复 EntityFramework dll。为此,我必须在命令提示符处右键单击并选择“以管理员身份运行”,然后尝试卸载 dll。

轰!!这就是我所缺少的。

【讨论】:

    猜你喜欢
    • 2015-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-17
    • 1970-01-01
    • 2019-04-13
    • 1970-01-01
    相关资源
    最近更新 更多