Using MySQL with EF6. DbConfiguration Error
I was trying my hands on using MySQL with Entity Framework 6. All went well, until I ran it ;)
After installing MySQL.Data, MySQL.Data.Entities and coding my DbContext, I pressed F5. I was greeted by following:
Server Error in '/' Application. The default DbConfiguration instance was used by the Entity Framework before the 'MySqlEFConfiguration' type was discovered. An instance of 'MySqlEFConfiguration' must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The default DbConfiguration instance was used by the Entity Framework before the 'MySqlEFConfiguration' type was discovered. An instance of 'MySqlEFConfiguration' must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information. Source Error: Line 11: public class MySQLDbContext : DbContext Line 12: { Line 13: public MySQLDbContext() Line 14: : base("MyApp") Line 15: {
There are various things suggested on internet like updating packages, changing assembly binding redirects in web.config. But after going throught the documentation on MySql forum and some questions on StackOverflow, I was missing following in Application_Start():
DbConfiguration.SetConfiguration(new MySqlEFConfiguration());











