Migration to MySQL and Schema specified is not valid

entity-framework entity-framework-6 entity-framework-6.1 mysql

Question

With the exception of one problem, I have moved my SQL2012 Database to MySQL.

When I try to connect to the MySQL Database, I get the following error.

As the database was being initialized, an exception happened.

InnerException for more information The supplied schema is invalid. (0, 0) errors The Type nvarchar(max) is not qualified with a namespace or alias, according to error code 0040. It is only possible to utilize primitive types without restriction.

Every String property in my classes experiences this.

I've tried these things:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
        { modelBuilder.HasDefaultSchema(String.Empty);}

But I continue to receive the error.

Do you know of any solutions that might help with the problem?

Additionally, I've attempted to create a MySQL migration, but I keep getting 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.

Do you know how to set the MySQLProvider in code?

My DBConfiguration is as follows:

    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());
    }

I added the following to fix the issue with moving the history table:

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)); 
        }
    }
1
0
12/30/2014 8:14:06 PM

Popular Answer

The answer is to insert the following phrase:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
  if (CustomConnectionFactory.ServerName == "MySQL")
  {
    modelBuilder.Properties<String>().Configure(c => c.HasColumnType("longtext"));
  }}

The second response offered here includes crucial details for setting up the two distinct databases.

0
5/23/2017 12:12:49 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow