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();
}
}
}