Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while running Update-Database in MVC5

I have a MVC 5 app, that has MySQL database hosted in Azure. It was working all well, but today when I tried to type Update-Database and run it, I got the following error message:

System.Runtime.Serialization.SerializationException: Type is not resolved for member 'MySql.Data.MySqlClient.MySqlException,MySql.Data, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Type is not resolved for member 'MySql.Data.MySqlClient.MySqlException,MySql.Data, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.

What can be the problem, and how can I solve it?

like image 717
tett Avatar asked Nov 07 '14 17:11

tett


2 Answers

I had this problem before:

1.- Install an update the mysql connector to the new version: http://dev.mysql.com/downloads/connector/net/

2.- Because you are trying to connect to a remote installation of MySQL you have to make sure that the port is open. You can try to connect to a local MySQL DB to verify this.

I hope this work for you too.

like image 80
Goca Avatar answered Sep 29 '22 12:09

Goca


Just in case someone else stumbled upon this "Type is not resolved for member" error:

This message is very misleading because it is shown for many issues that have nothing to do with what you may assume from this message.

Most of the time I was running into into this message it was some code within a mapped class throwing an exception while the Seed method was executing. Watch out for custom ToString() and GetHashCode() implementations.

The VS debugger is your best friend in this case. Just add the following code to your Seed() method:

   if (System.Diagnostics.Debugger.IsAttached == false)
      System.Diagnostics.Debugger.Launch();

Launch a second VS instance with your project before running the Update-Database command and you should see what is wrong.

like image 24
Marcus Avatar answered Sep 29 '22 10:09

Marcus