EF6 with MySQL. The given key was not present in the dictionary

前端 未结 3 881
抹茶落季
抹茶落季 2021-01-25 00:16

I have Asp.Net MVC 5 application using Code First Entity Framework 6 linked to MySQL database.

When I created the database first time, it works fine. But when I make a c

相关标签:
3条回答
  • 2021-01-25 00:37

    Bug 75172 It is a bug reported in version 6.9.4,but I review it in 6.9.11.

    0 讨论(0)
  • 2021-01-25 00:50

    Don't apply the newest mysql tools

    1. Close Visual studio 2017

    2. Uninstall mysql-for-visualstudio 2.0.5 Then, install mysql-for-visualstudio 1.2.8

    3. Uninstall mysql-connector-net-8.0.17 Then, install mysql-connector-net-6.9.10. Find the mysql.data.dll, MySql.Data.Entity.EF6.dll in %Program Files (x86)%\MySQL\MySQL Connector Net 6.9.10\Assemblies\v4.5 Add to reference

    4. Open nuget in references, downgrade EntityFramework 6 to EntityFramework 5

    0 讨论(0)
  • 2021-01-25 00:57

    As you see from the first lines of the error,

    MySql.Data.MySqlClient.MySqlConnectionStringBuilder.<>c.<.cctor>b__2_7(MySqlConnectionStringBuilder msb, MySqlConnectionStringOption sender) at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.get_Item(String keyword)

    the error has to do with the ConnectionString. The problem is the ConnectionString contains keys that can't be read.

    Try to clean up the ConnectionString so that it has only

    1. server
    2. user id
    3. password
    4. database

    In my case, the ConnectionString had an extra key integrated security. When this was removed Update-Database started working fine. Depending on your case however, this might and might not be the key that caused the error.

    So again my proposed and guaranteed solution, go through ConnectionString and simplify it so that it contains only the 4 keys mentioned above.

    0 讨论(0)
提交回复
热议问题