+1-888-365-2779
Try Now
More in this section

Forums / Thunder / Thunder Custom Module with Entity Framework and MySQL

Thunder Custom Module with Entity Framework and MySQL

2 posts, 0 answered
  1. Mikyle
    Mikyle avatar
    3 posts
    Registered:
    15 Mar 2016
    21 Jun
    Link to this post

    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/{{filename}}EfDataProvider.cs file, in the Get{{Classname}}ModuleItems() 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

     

     

     

     

  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    08 Dec 2016
    12 Jul
    Link to this post
    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
     
2 posts, 0 answered