locked
The Entity Framework provider ... could not be loaded RRS feed

  • Question

  • User-789623466 posted

    I created a very simple CodeFirst Console app using EF6, based on a CodeProject article (2015 IIRC). It worked perfectly. I modified it to use MySQL, and it throws an error at: public Context() : base(). What do I need to fix it?

    Here is the error: System.InvalidOperationException
    HResult=0x80131509
    Message=The Entity Framework provider type 'MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6' registered in the application config file for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
    Source=EntityFramework

    MySQL\Connector.NET 6.9.10, "MySQL for Visual Studio" v2.0.5. These were part of the app while using a SQL Server DB and working. Here is my app.config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework"
    type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    requirePermission="false"/>
    </configSections>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
    </startup>
    <entityFramework>
    <providers>
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    </providers>
    </entityFramework>
    </configuration>

    Here is my program.cs: using System;

    namespace CodeFirstConsole
    {
    class Program
    {
    static void Main(string[] args)
    {
    Console.WriteLine("Adding an Employee...");
    using (var ctx = new Context())
    {
    Employee emp = new Employee() { Name = "Singer" };
    ctx.Employees.Add(emp);
    ctx.SaveChanges();
    Console.WriteLine("Employee Saved!");

    foreach (var emply in ctx.Employees)
    {
    string line = emply.EmployeeID.ToString() + " " + emply.Name;
    Console.WriteLine(line);
    }
    }

    Console.ReadLine();
    }
    }
    }

    Tuesday, January 28, 2020 8:50 PM

Answers

  • User665608656 posted

    Hi JonJacobs,

    Here is the error: System.InvalidOperationException
    HResult=0x80131509
    Message=The Entity Framework provider type 'MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6' registered in the application config file for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
    Source=EntityFramework

    For this issue,  you can modify the content of your app.config according to this reply.

    If it still cannot solve it, you can refer to other replies in this link for more reference:

    Unable to Connect to MySQL in ASP.NET MVC using Entity Framework 6.0.0.0

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 29, 2020 2:06 AM

All replies

  • User665608656 posted

    Hi JonJacobs,

    Here is the error: System.InvalidOperationException
    HResult=0x80131509
    Message=The Entity Framework provider type 'MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6' registered in the application config file for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
    Source=EntityFramework

    For this issue,  you can modify the content of your app.config according to this reply.

    If it still cannot solve it, you can refer to other replies in this link for more reference:

    Unable to Connect to MySQL in ASP.NET MVC using Entity Framework 6.0.0.0

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 29, 2020 2:06 AM
  • User-789623466 posted

    Thank you. Your link gave me the information I needed.

    Thursday, January 30, 2020 3:51 PM