Entity Framework 将 MySql 与 ASP.Net MVC 一起使用时出现 IndexAttribute 错误
Entity Framework IndexAttribute error when Using MySql with ASP.Net MVC
我想让我的 mvc 应用程序连接到 MySQL
数据库,我从早上开始就完成了以下步骤,但我遗漏了一些东西。
- 已为
.Net
安装 MySQL
连接器(连接器 ODBC
5.3)
- 已安装(
MySQL
用于 Visual Studio 1.2.6)
- 按照教程学习
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
现在,当我 运行 网站并尝试注册时,它崩溃了,说
Could not load type
'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from
assembly 'EntityFramework, Version=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
- EntityFramework.SqlServer
- Microsoft.AspNet.Identity.EntityFramework
- MySql.Data
- MySql.Data.Entity.EF6
我也加了
MySql.Data.Entity
来自 (MySQL
for Visual Studio 1.2.6) 中的程序集
我是 MVC 和 MySQL
的新手。所以,对于可能出现的问题并不清楚。
更新 有人在另一个 post 上建议我需要将其从 gacutil 中删除。现在 gacutil 说我需要管理员权限才能删除已经有的程序集..有解决办法吗?这是正确的解决方案吗?
好吧,我尝试的更新是正确的。所以问题是我在 gac 中有一个版本为 6.0.0.0 的重复 EntityFramework dll。为此,我必须在命令提示符下 right-click 并选择 "run as administrator" 然后尝试卸载 dll。
砰!!这就是我所缺少的。
我想让我的 mvc 应用程序连接到 MySQL
数据库,我从早上开始就完成了以下步骤,但我遗漏了一些东西。
- 已为
.Net
安装MySQL
连接器(连接器ODBC
5.3) - 已安装(
MySQL
用于 Visual Studio 1.2.6) - 按照教程学习
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
现在,当我 运行 网站并尝试注册时,它崩溃了,说
Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=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
- EntityFramework.SqlServer
- Microsoft.AspNet.Identity.EntityFramework
- MySql.Data
- MySql.Data.Entity.EF6
我也加了
MySql.Data.Entity
来自 (MySQL
for Visual Studio 1.2.6) 中的程序集
我是 MVC 和 MySQL
的新手。所以,对于可能出现的问题并不清楚。
更新 有人在另一个 post 上建议我需要将其从 gacutil 中删除。现在 gacutil 说我需要管理员权限才能删除已经有的程序集..有解决办法吗?这是正确的解决方案吗?
好吧,我尝试的更新是正确的。所以问题是我在 gac 中有一个版本为 6.0.0.0 的重复 EntityFramework dll。为此,我必须在命令提示符下 right-click 并选择 "run as administrator" 然后尝试卸载 dll。
砰!!这就是我所缺少的。