Samra
Samra

Reputation: 2015

Entity Framework IndexAttribute error when Using MySql with ASP.Net MVC

I want my mvc application to connect to MySQL database and I have done the following steps since morning but am missing something.

  1. Installed MySQL Connector for .Net (Connector ODBC 5.3)
  2. Installed (MySQL for Visual Studio 1.2.6)
  3. Followed the tutorial https://learn.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 installed entityframework 6.1.3

now when I run the website and try to register, it crashed saying

Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0

my .csproj file contains

<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>

My application references include:

I also added

I am new to both MVC and MySQL. So, don't have a clear picture of what could go wrong.

UPDATE Someone suggested on another post that i need to remove it from the gacutil. Now gacutil is saying i need admin privileges to remove an assembly which already have.. Is there a work around? is this the right-solution?

Upvotes: 0

Views: 356

Answers (1)

Samra
Samra

Reputation: 2015

Well, the update i was trying was correct. So the problem was that i had a duplicate EntityFramework dll with version 6.0.0.0 in the gac. And to do that i had to right-click on command prompt and choose "run as administrator" and then try uninstalling the dll.

BOOM!! This was what i was missing.

Upvotes: 0

Related Questions