本文介绍了实体框架代码首先 - Firebird迁移:否MigrationSqlGenerator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种更新我的firebird数据库的方法。我尝试使用迁移:

  private void btnUpdateDb_Click(object sender,EventArgs e)
{
DbConnection userDBConnection = ClassBasicRepository.GetDBConnection();

var configuration = new Configuration();
configuration.TargetDatabase = new DbConnectionInfo(
userDBConnection.ConnectionString,
FirebirdSql.Data.FirebirdClient);

DbMigrator migrator = new DbMigrator(configuration);
migrator.Update();
}

DbMigrationsConfiguration:

  public sealed class配置:DbMigrationsConfiguration< BaseDbContext> 
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
//SetSqlGenerator(\"FirebirdSql.Data.FirebirdClient,new FirebirdSql.Data.Entity。???);
}

protected override void Seed(BaseDbContext context)
{
MigrationsAssembly = Assembly.GetExecutingAssembly();
MigrationsNamespace =MyServices.Data.Migrations;
}
}

migrator.Update()给了我以下例外:

我必须在配置中指定一个MigrationSQLGenerator。但是我在FirebirdClient.dll中找不到。我发现唯一的解决办法是自行重写:



一个Firebird特定的MigrationSQLGenerator是否真的有必要,而不是不提供迁移?



我的环境:
EntityFramework 5.0.0
.NET 4.5
FirebirdClient 3.0.2.0

解决方案

目前不支持迁移。实际上您可以使用迁移,但是您必须生成脚本并将其更改为适合Firebird风味SQL。


I'm searching for a way to update my firebird-database. I tried using migrations:

    private void btnUpdateDb_Click(object sender, EventArgs e)
    {
        DbConnection userDBConnection = ClassBasicRepository.GetDBConnection();

        var configuration = new Configuration();
        configuration.TargetDatabase = new DbConnectionInfo(
            userDBConnection.ConnectionString,
            "FirebirdSql.Data.FirebirdClient");

        DbMigrator migrator = new DbMigrator(configuration);
        migrator.Update();
    }

DbMigrationsConfiguration:

public sealed class Configuration : DbMigrationsConfiguration<BaseDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
        //SetSqlGenerator("FirebirdSql.Data.FirebirdClient", new FirebirdSql.Data.Entity.???);
    }

    protected override void Seed(BaseDbContext context)
    {
        MigrationsAssembly = Assembly.GetExecutingAssembly();
        MigrationsNamespace = "MyServices.Data.Migrations";
    }
}

"migrator.Update()" gives me the following Exception:

I have to specify a MigrationSQLGenerator in the Configuration. But I can't find it in the FirebirdClient.dll. The only solution I found was to rewrite it on my own:https://github.com/mrward/entityframework-sharpdevelop/blob/master/src/EntityFramework/Migrations/Sql/SqlCeMigrationSqlGenerator.cs

Is a Firebird specific MigrationSQLGenerator really necessary and not not provided to enable migrations?

My Environment:EntityFramework 5.0.0.NET 4.5FirebirdClient 3.0.2.0

解决方案

Migrations are currently not supported. Actually you can use migrations, but you'll have to generate the script and change it to fit Firebird-flavor SQL.

这篇关于实体框架代码首先 - Firebird迁移:否MigrationSqlGenerator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 14:29
查看更多