I have migrated SQL2012 Database to MySQL, apart from one issue.
I get the following error when I connect to the MySQL Database.
An exception occurred while initializing the database.
InnerException for details: Schema specified is not valid. Errors: (0,0) : error 0040: The Type nvarchar(max) is not qualified with a namespace or alias. Only primitive types can be used without qualification.
This occurs for every String property in my classes.
I have tried the following:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{ modelBuilder.HasDefaultSchema(String.Empty);}
However I still get the error.
Does anybody have suggestions that may resolve the issue.
I have also tried to generate a MySQL migration but I get the following error:
No Entity Framework provider found for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Is there a way of setting the MySQLProvider in Code?
Here is my DBConfiguration:
public class EF6MySQLDbConfiguration : DbConfiguration
{
public EF6MySQLDbConfiguration()
{
if (CustomConnectionFactory.ServerName == "MySQL")
{
SetExecutionStrategy(MySql.Data.Entity.MySqlProviderInvariantName.ProviderName, () => new MySql.Data.Entity.MySqlExecutionStrategy());
AddDependencyResolver(new MySql.Data.Entity.MySqlDependencyResolver());
//Type t = typeof(MySqlProviderServices);
}
SetDefaultConnectionFactory(new CustomConnectionFactory());
}
To overcome the problem when migrating the history table I added:
public Configuration()
{
AutomaticMigrationsEnabled = false;
if (EF6MySQL.DataAccess.CustomConnectionFactory.ServerName == "MySQL")
{
SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator());
SetHistoryContextFactory("MySql.Data.MySqlClient", (conn, schema) => new MySql.Data.Entity.MySqlHistoryContext(conn, schema));
}
}