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

4
  • can you share your connection string and context class ? Commented Sep 22, 2016 at 9:46
  • stackoverflow.com/a/19898907/6356434 Commented Sep 22, 2016 at 9:47
  • and also code of the models ? Commented Sep 22, 2016 at 9:50
  • You need to make sure the provider is correctly registered, have a look at the link @Alex shared Commented Sep 22, 2016 at 9:50

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.