Error connecting to the database using the Entity Framework

0

I'm creating a WPF application, and I decided to use EntityFramework to perform the operations in my bank. I created a data model from an existing database in my MySQL Workbench, and the process was executed correctly, exporting all the tables and generating a context for them.

However, when I want to perform any type of operation in the application, such as inserting data into a table, for example, the program locks and closes automatically (without giving any error message). And the data is also not being stored in the database.

The code that is giving error is as follows:

private void Button_Click(object sender, RoutedEventArgs e)
    {
        using (maisfilmesEntities ctx = new maisfilmesEntities())
        {
            usuario u = new usuario
            {
                login = "Teste",
                senha = "teste"
            };
            ctx.usuario.Add(u);
            ctx.SaveChanges();
        }
    }

Exceptions generated:

MySql.Data.MySqlClient.MySqlException (0x80004005): The host localhost does not support SSL connections.
em MySql.Data.MySqlClient.NativeDriver.Open()
em MySql.Data.MySqlClient.Driver.Open()
em MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
em MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
em MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
em MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
em MySql.Data.MySqlClient.MySqlPool.GetConnection()
em MySql.Data.MySqlClient.MySqlConnection.Open()
em System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher <Open>b__36(DbConnection t, DbConnectionInterceptionContext c)

Error caught with try / catch:

  

The underlying provider failed on Open.

    
asked by anonymous 30.05.2018 / 19:55

1 answer

0

I believe you just need to add SslMode=none to your connection string.

See an example:

string connectionString = "ServerDoMeuBD;Database=MeuBD;Uid=Usuario;Pwd=Senha;SslMode=none;";

Read more about the connection string MySQL here .

    
06.01.2019 / 22:16