1

我想在 C# 中使用 linq2db 将数据库从 Firebird 迁移到 MSSQL。

我想我可以使用 Firebird 的 T4 模型加载结构,然后创建表并将数据批量复制到 MSSQL。

到目前为止一切顺利,但它将数据复制回 Firebird 而不是 MSSQL

这是我的 app.config:

<connectionStrings>
    <add name="Firebird__" connectionString="Data Source=localhost;Initial Catalog=MyDatabase;User Id=xxx;Password=yyy" providerName="Firebird" />
    <add name="MSSQL__" connectionString="Data Source=192.168.1.x,12345;Initial Catalog=myOtherDatabase;User Id=yyy;Password=xxx" providerName="MSSQL" />
  </connectionStrings>
  <system.data>
        <DbProviderFactories>
            <remove invariant="FirebirdSql.Data.FirebirdClient" />
            <add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
        </DbProviderFactories>
    </system.data></configuration>

然后在我的程序中我使用这个:

using (var db = new FirebirdDB())
        {
        var employeeQuery =
              from m in db.employee
              orderby m.NAME
              select m;

            liste = employeeQuery.ToList();
        }
      //using (var db_MSSQL = new MSSQL())
        using (var db_MSSQL = new FirebirdDB("MSSQL__")) 
        {
            db_MSSQL.CreateTable<MSSQL_.MA_DATEN_NAME>();
            //db_MSSQL.BulkCopy(liste);

我在这里阅读了最后一条 using 语句(如何使用 LinqToDB 使用多个 SQLite 数据库

总是同样的问题,程序使用firebird连接而不是mssql。有任何想法吗?

4

1 回答 1

1

现在我找到了答案,谢谢 Arioch!

应用程序配置

providerName显然非常重要,我需要“ SqlServer.2012”

<connectionStrings>
<add name="Firebird__" connectionString="Data Source=localhost;Initial Catalog=MyDatabase;User Id=yy;Password=xx" providerName="Firebird" />
<add name="MSSQL__" connectionString="Data Source=192.168.1.x,12345;Initial Catalog=MyOtherDatabase;User Id=yy;Password=xx" providerName="SqlServer.2012" />
</connectionStrings>

在我的程序中:

这成功了:您在连接设置中使用参数“name”为连接命名,如果您有多个连接,这很有意义......

using (var db_MSSQL = new MSSQL("MSSQL__"))
        {
            db_MSSQL.CreateTable<MSSQL_.MA_DATEN_NAME>();
于 2018-10-24T13:05:39.660 回答