Entity Framework Code First + MySQL… NullReferenceException

会有一股神秘感。 提交于 2019-12-06 12:01:05

Have you tried to name your connection string DbContext ? It's name should match the class name.

Like this:

<add name="DbContext" connectionString="Server=111.222.333.444; Database=foo; Uid=foouser; Pwd=bar;" providerName="MySql.Data.MySqlClient" />

Haven't tried yet with MySql, but I had issues in the past with Sql Server when not naming properly the connection string.

Best regards!

Maybe this could help Entity Framework throws NullReferenceException with .NET 3.5

Another thing to be aware of is mysql lowercases column and table names so you should need to map Properties to field names when the model is defined.Custom Database Schema Mapping

Katulus

I found an answer here: MySQL with Entity Framework - what am I doing wrong?

Problem was with missing reference to MySql.Data.Entity in my project. After adding it, exception is gone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!