使用EntityFramework的连接字符串(MySQL)问题

时间:2019-04-30 18:21:22

标签: c# mysql

我必须将数据库从SQL Server更改为MySql,并且在更改app.config文件上的连接字符串时遇到了此问题:

<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, Version=6.10.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
   <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>

<connectionStrings>
 <add name="LattesDatabase" connectionString="metadata=res://*/Entities.Database.LattesDatabase.csdl|res://*/Entities.Database.LattesDatabase.ssdl|res://*/Entities.Database.LattesDatabase.msl; provider = MySql.Data.MySqlClient; provider connection string=&quot; data source = name=********* ; initial catalog = farol_db; integrated security=False; User id = name= *********; Password = ********; App= EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

错误:

The underlying provider failed on ConnectionString.

堆栈:

   at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString)
   at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
   at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)

对我来说,连接字符串似乎正确。 谁能给我一些建议?我已经尽我所能在Google上找到了一切。

0 个答案:

没有答案