0

I'm new with .net I'm trying building console app with EF6 and MySql

i always got this error when running it enter image description here

this is my app.conf

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <connectionStrings>
    <add name="MyContext" providerName="MySql.Data.MySqlClient"
        connectionString="server=192.168.1.212;port=3306;database=zkatt;uid=fanta;password=040506"/>
  </connectionStrings>
  <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient"
          type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/>
      <provider invariantName="System.Data.SqlClient"
          type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description="MySQL Database Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
    </DbProviderFactories>
  </system.data>
</configuration>

my context class

[DbConfigurationType(typeof(MySqlEFConfiguration))]
public partial class Entities : DbContext
{
    public Entities()
        : base("name=MyContext")
    {
    }

anything i miss?

*edit this is full report error enter image description here

10
  • Have you tried to uninstall and reinstall EF6 and MySql nuget packages ? Commented Dec 7, 2017 at 9:37
  • yes, i have try it. I have try to search all over the google for 6 hours, nothing work Commented Dec 7, 2017 at 9:39
  • Try writing base("MyContext") instead of base("name=MyContext") Commented Dec 7, 2017 at 9:43
  • @KaranDesai same error Commented Dec 7, 2017 at 9:44
  • okay now try putting your connection string in there and let me know whether it worked or not Commented Dec 7, 2017 at 9:45

2 Answers 2

1

Remove the useless node :

<DbProviderFactories>
  <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description="MySQL Database Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
</DbProviderFactories>

And specify version of your MySqlClient provider like :

<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
Sign up to request clarification or add additional context in comments.

1 Comment

<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider> same error
1

Downgrade mysql entity to 6.9.10, now its work, wasted my 6 hours.

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.