Original: http://lvasquez.github.io/2014/11/18/EntityFramework-MySql/
For the Entity Framework 6 support We need to has this requirements
- MySQL connector/net 6.8.x
- MySQL Server 5.1 or above
- Entity Framework 6 Assemblies
- . NET Framework 4.0 or above
I'll use the concept of DataBase first but without using the Visual Studio Wizard to create the Edmx file, so instead of That, I'll do it manually. I'll create a Console application, so first install the Entity Framework via Nuget Package
Install-Package EntityFramework
Install-Package MySql.Data.Entity.EF6
Add the connection string in the App.confing
The app.confing should is like this
<?xml version="1.0"encoding="Utf-8"?><configuration> <configSections> <!--for more information on Entity Framework configuration, Visi T 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> <connectionStrings> <add name="monkeyfist"connectionstring="Server=localhost;user Id=root;password=mypass;database=mydb"Providername="MySql.Data.MySqlClient"/> </connectionStrings> <startup> <supportedruntime version="v4.0"sku=". netframework,version=v4.5"/> </startup> <entityFramework> <defaultconnectionfactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/> <providers> <provider invariantname="MySql.Data.MySqlClient"Type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/> <provider invariantname="System.Data.SqlClient"Type="System.Data.Entity.SqlServer.SqlProviderServices, Entityframework.sqlserver"/> </providers> </entityFramework><system.data> <DbProviderFactories> <remove in Variant="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.8.3.0, Culture=neutral, publickeytoken= C5687FC88969C44D"/> </DbProviderFactories> </system.data> <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyidentity name="EntityFramework"publickeytoken="b77a5c561934e089"Culture="Neutral"/> <bindingredirect oldversion="0.0.0.0-6.0.0.0"newversion="6.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime></configuration>
Go to EF using my step--entity Framework 6 with MYSQL