I'm setting up a solution containing two projects: 1) my class library and 2) my web UI. Ultimately the website will be used to show query results from an existing mysql database.
I struggled to create the ado.net entity model for a while. But I thought I had figured it out after updating the mysql connector for visual studio and following the instructions here: https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html
Now that the entity model is created I am struggling to create a simple controller with scaffolding. I've double checked my connection string and ef provider in web.config and app.config.
I've looked through these questions but have not found my answer:
Exception has been thrown by the target of an invocation- while creating the controller
Application can't scaffold items
I'm pretty sure the issue is in how I have configured it. For a while I thought that what is in app.config didn't matter because the UI project (containing web.config) was set as the startup project. Now I'm just confused. Which is why I have included both below. Any insight is greatly appreciated.
From web.config:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-MySolution.UI-20161111094519.mdf;Initial Catalog=aspnet-MySolution.UI-20161111094519;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MySolutionEntities" connectionString="metadata=res://*/Entities.DevData.csdl|res://*/Entities.DevData.ssdl|res://*/Entities.DevData.msl;provider=MySql.Data.MySqlClient;provider connection string="server=****;user id=****;password=****;database=mydatabase""
providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="System.Data.MySqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFrameworkSqlServer" />
</providers>
</entityFramework>
From 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>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient"
type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="MySql.Data.SqlClient"
type="MySql.Data.Entity.SqlServer.ProviderServices, EntityFramework.SqlServer"/></providers>
</entityFramework>
<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>
</system.data>
<connectionStrings>
<add name="MySolutionEntities" connectionString="metadata=res://*/Entities.DevData.csdl|res://*/Entities.DevData.ssdl|res://*/Entities.DevData.msl;provider=MySql.Data.MySqlClient;provider connection string="server=****;user id=****;password=****;database=mydatabase""
providerName="System.Data.MySqlClient" />
</connectionStrings>
</configuration>