0
I have a project where I need to use Mysql as a database and EF6 with the CODE FIRST approach.
I installed Mysql.Data.Entity 6.9.9 and Entityframework 6.1.3
My app.config looks like this:
<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>
<connectionStrings>
<add name="MyContext" providerName="MySql.Data.MySqlClient"
connectionString="server=localhost;port=3306;database=MyContext;uid=user;password=***"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
</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>
When I run update-database I get the following message:
Target database is: 'Mycontext' (Datasource: . SQLEXPRESS, Provider: System.Data.Sqlclient, Origin: Convention).
VS2015 is creating the database in SQLEXPRESS, which I need to change to use Mysql?
app.confg? is windows Forms your application ? you are putting your connectionString in the right place ?:
– Marco Souza
It’s actually a multi-layered web MVC. The data layer is a library class. The connection is in the right place.
– b3r3ch1t
ok, but I believe that the application (class library) uses the web.config of the UI project and not itself.
– Marco Souza
In my Solution had not yet put the MVC application. Thanks for the tip
– b3r3ch1t