2
I did the procedures outlined in these questions:
Entity Framework - Bank Compatibility
Error Mysql Connection Asp.net MVC
I installed Mysql.Data.Entities.
My web.config looked like this:
<connectionStrings>
<add name="BancoDados" connectionString="Server=xxx;
Database=xxx;
Uid=xxx;
Pwd=xxx;"
providerName="System.Data.EntityClient"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
</providers>
</entityFramework>
But when executing Add-Migration
fires the following error:
Keyword not supported: 'server'.
I tried to change the providerName
for MySql.Data.MySqlClient
, triggered the following error:
The ADO.NET Provider with invariant name 'Mysql.Data.Mysqlclient' is either not Registered in the machine or application config file, or could not be Loaded. See the Inner Exception for Details.
When installing the . Net Connector 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 System.Data.Entity.Utilities.Dbproviderservicesextensions.Getprovidermanifesttokenchecked(Dbproviderservices providerServices, Dbconnection Connection) at System.Data.Entity.Infrastructure.Defaultmanifesttokenresolver.<>c__DisplayClass1.b__0(Tuple
3 k) at System.Collections.Concurrent.ConcurrentDictionary
2.Getoradd(Tkey Key, Func2 valueFactory) at System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy
2.Getvalue(Tinput input) at System.Data.Entity.Internal.Lazyinternalcontext.Initializecontext()
at System.Data.Entity.Internal.Lazyinternalcontext.get_ModelBeingInitialized() At System.Data.Entity.Infrastructure.Edmxwriter.Writeedmx(Dbcontext context, Xmlwriter Writer) at System.Data.Entity.Utilities.Dbcontextextensions.<>c__DisplayClass1.b__0(Xmlwriter w) at System.Data.Entity.Utilities.Dbcontextextensions.Getmodel(Action`1 writeXml) at System.Data.Entity.Utilities.Dbcontextextensions.Getmodel(Dbcontext context) at System.Data.Entity.Migrations.Dbmigrator.. ctor(Dbmigrationsconfiguration Configuration, Dbcontext usersContext, Databaseexistencestate existenceState, Boolean calledByCreateDatabase) at System.Data.Entity.Migrations.Dbmigrator.. ctor(Dbmigrationsconfiguration Configuration) at System.Data.Entity.Migrations.Design.MigrationScaffolder.. ctor(Dbmigrationsconfiguration migrationsConfiguration) at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffoldrunner.Run() At System.AppDomain.Docallback(Crossappdomaindelegate callBackDelegate) at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
At System.Data.Entity.Migrations.Design.ToolingFacade.Run(Baserunner Runner) at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges) at System.Data.Entity.Migrations.Addmigrationcommand.Execute(String name, Boolean force, Boolean ignoreChanges) at System.Data.Entity.Migrations.Addmigrationcommand.<>c__DisplayClass2. <. ctor>b__0() at System.Data.Entity.Migrations.Migrationsdomaincommand.Execute(Action command) Object Reference not set to an instance of an Object.
Installed . Net Connector? http://dev.mysql.com/downloads/connector/net/
– Leonel Sanches da Silva
No, I just installed Mysql.Data.Entities.
– Diego Zanardo
So install and repeat the test, please.
– Leonel Sanches da Silva
@Ciganomorrisonmendez, the following error: "Object Reference not set to an instance of an Object."
– Diego Zanardo
This error could be anything. You can please put the Stack Trace in the body of the question?
– Leonel Sanches da Silva
@Gypsy!
– Diego Zanardo
In this answer here the author of the question has the same problem as you. It may be or a problem of setting the
web.config
or it is the Nector that has some bug. In the most voted answer has to expand this setting. Could check, please?– Leonel Sanches da Silva
Thanks @Ciganomorrisonmendez, I got... But now I have another problem... http://answall.com/questions/40138/publicar-aplica%C3%A7%C3%A3o-com-Entity-framework-mysql
– Diego Zanardo
What was done to solve? I still want to add the answer.
– Leonel Sanches da Silva
@Ciganomorrisonmendez, I installed the . net Connector and let the connectiostring so:
<add name="BancoDados" providerName="MySql.Data.MySqlClient" connectionString="Data Source=xxxx; port=3306; Initial Catalog=bancoMySQL; uid=usuarioMySQL; pwd=qwe123qwe;" />
– Diego Zanardo