Hello devart Team,
Even though I put
---
MySqlEntityProviderConfig config = MySqlEntityProviderConfig.Instance;
config.Workarounds.IgnoreSchemaName = true;
config.Workarounds.IgnoreDboSchemaName = true;
----
in Context constructor, I am still seeing "dbo." prefix in automatically generated migration code by Package Manager Console (> add-migration test).
Is this expected behavior or is there an option to avoid this?
(For MySQL Connector/Net, I fixed this issue by setting code generator, but I don't see this in devart dotConnector for MySQL)
---
CodeGenerator = new MySqlMigrationCodeGenerator(); // does not exist in devart lib, also cannot assign "new MySqlEntityMigrationSqlGenerator()"
---
The following are the codes I tested.
--------------
/* Program.cs */
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using Devart.Data.MySql.Entity.Configuration;
namespace dotConnectForMySqlTest
{
public class Student
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int StudentID { get; set; }
public string StudentName { get; set; }
public DateTime? DateOfBirth { get; set; }
public byte[] Photo { get; set; }
public decimal Height { get; set; }
public float Weight { get; set; }
//public string NewProperty { get; set; } // newly added property
}
public class SchoolContext : DbContext
{
public SchoolContext()
{
MySqlEntityProviderConfig config = MySqlEntityProviderConfig.Instance;
config.DatabaseScript.Schema.DeleteDatabaseBehaviour = Devart.Data.MySql.Entity.Configuration.DeleteDatabaseBehaviour.Database;
config.Workarounds.IgnoreSchemaName = true;
config.Workarounds.IgnoreDboSchemaName = true;
Database.SetInitializer(new CreateDatabaseIfNotExists<SchoolContext>());
}
public DbSet<Student> Students { get; set; }
}
class Program
{
static void Main(string[] args)
{
using (var ctx = new SchoolContext())
{
Student stud = new Student() { StudentName = "New Student" };
ctx.Students.Add(stud);
ctx.SaveChanges();
}
}
}
}
--------------
/* Configuration.cs */
using System.Data.Entity.Migrations;
using Devart.Data.MySql.Entity.Migrations;
namespace dotConnectForMySqlTest
{
internal sealed class Configuration : DbMigrationsConfiguration<SchoolContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
AutomaticMigrationDataLossAllowed = true;
SetSqlGenerator(MySqlConnectionInfo.InvariantName, new MySqlEntityMigrationSqlGenerator());
ContextKey = "dotConnectForMySqlTest.SchoolContext";
}
protected override void Seed(SchoolContext context)
{
// This method will be called after migrating to the latest version.
}
}
}
--------------
/* 201503302136166_test.cs (automatically generated)*/
namespace dotConnectForMySqlTest.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class test : DbMigration
{
public override void Up()
{
AddColumn("dbo.Students", "NewProperty", c => c.String());
}
public override void Down()
{
DropColumn("dbo.Students", "NewProperty");
}
}
}
Database code-first migration problem (EF6.1.3, dotConnector for MySql 8.3.379)
Re: Database code-first migration problem (EF6.1.3, dotConnector for MySql 8.3.379)
By default, dotConnect for MySQL ignores the "dbo." prefix in EF Migrations code.kim10987 wrote:I am still seeing "dbo." prefix in automatically generated migration code by Package Manager Console (> add-migration test)
Generator of the EF Migrations code is implemented by Microsoft for SQL Server. That's why this prefix is generated. We think that implementing dotConnect for MySQL-specific code generator for EF Migrations doesn't make sence because it will not bring the new functionality.
Re: Database code-first migration problem (EF6.1.3, dotConnector for MySql 8.3.379)
More information:
EF6 -> http://blog.devart.com/entity-framework ... force.html
Code-First Migrations -> http://blog.devart.com/entity-framework ... qlite.html
EF6 -> http://blog.devart.com/entity-framework ... force.html
Code-First Migrations -> http://blog.devart.com/entity-framework ... qlite.html
Re: Database code-first migration problem (EF6.1.3, dotConnector for MySql 8.3.379)
MySqlCSharpMigrationCodeGenerator and MySqlVisualBasicMigrationCodeGenerator for code-based migrations are implemented for EF4, EF5, EF6 in the newest (8.6.699) build of dotConnect for MySQL.