簡體   English   中英

linq2db具有2個不同的數據庫來遷移數據庫

[英]linq2db with 2 different Databases to migrate a database

我想使用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。 有任何想法嗎?

現在我找到了答案,謝謝阿里奧奇!

App.config中

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>

在我的程序中:

這可以達到目的:在連接設置中為連接命名,並使用參數“名稱”命名 ,如果您有多個連接,則很有意義...

using (var db_MSSQL = new MSSQL("MSSQL__"))
        {
            db_MSSQL.CreateTable<MSSQL_.MA_DATEN_NAME>();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM