Error connecting to database (mysql) using entityFramework

Asked

Viewed 71 times

1

When trying to connect in the database I get this message: The underlying Provider failed on Connectionstring.

<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>

I believe my connection string is correct, will someone give me some light?

Error stack:

The underlying provider failed on ConnectionString.
   em System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   em System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString)
   em System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
   em System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
   em System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   em System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
   em System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   em System.Data.Entity.Internal.InternalContext.Initialize()
   em System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   em System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   em System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   em System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   em System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
  • Hello, welcome to Stackoverflow. Brother, if possible put in your post the full stack of error. So it looks better to help you.

  • Oops, I edited there, if I could take a look, it would help me a lot

  • How did you mount this string? took a look at the documentation? https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html

1 answer

2


Your connection string is wrong, remove the " and replace the &quotes for '

<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='data source = name=********* ; initial catalog = farol_db; integrated security=False; User id = name= *********; Password = ********; App= entityFramework'" providerName="System.Data.EntityClient" />
</connectionStrings>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.