Thunder Custom Module with Entity Framework and MySQL
I tried creating a new module project using Thunder utilizing Entity Framework and connecting to a MySQL database.
I followed the tutorial at: http://docs.sitefinity.com/thunder-develop-a-custom-module-using-an-entity-framework-data-provider
After the project was created, I tried to run an Automatic Code First Migration using the steps detailed on the link referenced above. When I got to 1.d, I got an exception
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Data.Entity.SqlServer.SqlProviderServices' threw an exception. ---> System.TypeLoadException: Method 'ExecuteAsync' in type 'System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy' from assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' does not have an implementation.
I tool the tutorial into my own hands.
To fix this, in the package manager console, I ran:
Install-Package MySql.Data.Entity
And in Migrations/Configuration.cs I made the Configuration() constructor look like the following:
public
Configuration()
AutomaticMigrationsEnabled =
true
;
// register mysql code generator
SetSqlGenerator(
"MySql.Data.MySqlClient"
,
new
MySql.Data.Entity.MySqlMigrationSqlGenerator());
Finally, I could run the update-database command as instructed in the tutorial.
After Building and installing the module, I navigated to the newly created backend page under the content menu. In the Data/EntityFramework/filenameEfDataProvider.cs file, in the GetClassnameModuleItems() method, I get this exception:
An exception of type 'System.ArgumentException' occurred in System.Data.dll but was not handled in user code
Additional information: Keyword not supported: 'characterset'.
I'm not sure how to fix this. Surely it is a problem with EF not setup correctly to work with MySQL. Any ideas?
See my project here: here
Hi,
The problem must be due to the connection string for entity framework which points to
providerName="System.Data.SqlClient"
providerName="System.Data.EntityClient"