Thunder Custom Module with Entity Framework and MySQL

Posted by Community Admin on 05-Aug-2018 20:39

Thunder Custom Module with Entity Framework and MySQL

All Replies

Posted by Community Admin on 21-Jun-2016 00:00

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

 

 

 

 

Posted by Community Admin on 12-Jul-2016 00:00

Hi,

The problem must be due to the connection string for entity framework which points to 

providerName="System.Data.SqlClient"
but it must be 
providerName="System.Data.EntityClient"

Regards,
Stanislav Velikov
Telerik by Progress
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed