1

I have setup entity framework 4.4.0 (EF5) code first migrations for a MySql database but when I run Add-Migration command I always get dbo prepended to the tablenames like so:

    CreateTable(
            "dbo.Fields",
            c => new
                {
                    FieldId = c.Int(nullable: false, identity: true),
                    FieldTypeId = c.Int(nullable: false),
                    Name = c.String(nullable: false, unicode: false),
                    Description = c.String(unicode: false),
                    CodeList = c.String(unicode: false),
                    Mask = c.String(unicode: false),
                })
            .PrimaryKey(t => t.FieldId)
            .ForeignKey("dbo.FieldTypes", t => t.FieldTypeId, cascadeDelete: true)
            .Index(t => t.FieldTypeId);

I'm using the Devart database provider and my migrations configuration class looks like this:

    internal sealed class Configuration : DbMigrationsConfiguration<mydbcontext>
{
    public Configuration()
    {
        // Create a custom connection to specify the database and set a SQL generator for MySql.
        var connectionInfo =
            MySqlConnectionInfo.CreateConnection("<<myconnectionstring>>");

        TargetDatabase = connectionInfo;

        SetSqlGenerator(connectionInfo.GetInvariantName(), new MySqlEntityMigrationSqlGenerator());

        var config = MySqlEntityProviderConfig.Instance;
        config.Workarounds.IgnoreSchemaName = true;

        AutomaticMigrationsEnabled = false;
    }

    protected override void Seed(CloudDataSetDbContext context)
    {

    }
}

For some reason the IgnoreSchemaName = true is not taken into account.

I added the Devart database provider to the web.config file like so:

    <system.data>
<DbProviderFactories>
  <remove invariant="Devart.Data.MySql" />
  <add name="dotConnect for MySQL" invariant="Devart.Data.MySql" description="Devart dotConnect for MySQL" type="Devart.Data.MySql.MySqlProviderFactory, Devart.Data.MySql, Version=6.80.350.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>

And I also added an assembly redirect because Devart needs this like so:

    <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
    <bindingRedirect oldVersion="4.3.1.0" newVersion="4.4.0.0" />
  </dependentAssembly>

Can anybody help me out here? Thx, Steven.

Steven Engels
  • 81
  • 1
  • 6

3 Answers3

0

Try configuring their Singleton config options before calling SetSqlGenerator. I have a fishy idea that they'll use the current settings as they were when the generator is set up, changing them afterwards won't change the behaviour of the generator.

Steve Py
  • 26,149
  • 3
  • 25
  • 43
0

We do not influence code generation for migrations content (code generation is done by Microsoft). We generate DDL based on migrations code. The "dbo" schema name specified in the code will be ignored when generating DDL.

Devart
  • 119,203
  • 23
  • 166
  • 186
0

I got the problem solved by upgrading DotConnect to the new 7.2.122 version. Now the __Migrations table gets created without dbo in front of it, so the insert statement works.

Steven Engels
  • 81
  • 1
  • 6