I'm trying to use MySQL database (ef code first approach, VS 2013 professional). I follow these instructions.
My problem is that after I enable migrations I cannot do a first migration. I use command Add-migration migrationName and I got an error:
"System.NullReferenceException: Object reference not set to an instance of an object. at MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection) at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) at MySql.Data.Entity.MySqlManifestTokenResolver.ResolveManifestToken(DbConnection connection) ...
Object reference not set to an instance of an object.".
I tried to solved it f.e. in this way. But now I found this:
"This can be caused by not specifying a required parameter for a scenario that you are using. For example specifying a connection string without specifying the provider name."
So the problem is probably in my connenctions string.
I have my connections string from VS > Server Explorer there is "active" connection to my database. I viewed the connection properties and copied a connection string into my web.config.
In my project are references to MySql.Data, MySql.Data.Entity.EF6 and MySql.Web.
Anyone have any ideas what should I do?
I've been here before at least twice for newly setup EF+MySQL projects, which give me the exact same error and stack trace as OP had, when trying to enable code first migrations. Both times it's taken me ages to find the solution that finally worked.
Do make sure your DbContext class has the following attribute:
[DbConfigurationType(typeof(MySqlEFConfiguration))]
class MyDbContext : DbContext
{
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With