1

I have configured all necessary to connect with MySQL with Entity Framwork in Visual Studio 2012

And all this is going well,

I get the mapping of my table in my code,

here is my code:

 using (testuserEntities context = new testuserEntities())
        {
            personels nam = context.personels.FirstOrDefault(x => x.name == "Walid");
            if (nam !=null )
            {
                textBox1.Text = nam.name;
            }                
        }

In the execution, I get the ERROR:

enter image description here

Thnaks,

The connection Strings :

<connectionStrings>
<add name="testuserEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;user id=root;password=root;persistsecurityinfo=True;database=testuser&quot;" providerName="System.Data.EntityClient"/>

my table :

enter image description here

devtunis
  • 141
  • 13

1 Answers1

2

I find the solution: We must update the DLL:

1) Right click on the Solution (top level in the solution explorer)

2) Manage Nuget packages for solution

3) Go to update ( locate in the left)

4) Update the packages :MySql.Data, MySql.Data.Entities, Entity.Framwork

we have change in the App.config file:

<system.data>
<DbProviderFactories>
  <remove invariant="MySql.Data.MySqlClient" />
  <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>

It works for me !!

devtunis
  • 141
  • 13