2013-11-14 98 views
0

我想知道SQLiteConnectionContext類的MySQL等價物是什麼。我需要這個能夠爲我的程序擁有一個通用的連接上下文。我正在創建一個基於實體的解決方案,它將推送和從MySQL數據庫中提取數據。如果有更好的方式來做到這一點,我也會接受。以下是我正在尋找的SQLite版本。MySQL的等價SQLite SQLiteConnectionContext

/// <summary> 
/// A ConnectionContext common for all of the Inventory project 
/// </summary> 
public class InventoryConnectionContext : SQLiteConnectionContext 
{ 
    public InventoryConnectionContext(bool connect = true) 
     : base(InventoryConnectionString, connect) 
    { 
    } 

    /// <summary> 
    /// Constructs a BudgetConnectionContext and optionally opens the connection 
    /// </summary> 
    /// <param name="connectString">Connection string that points to a connection aside from the default connection</param> 
    /// <param name="connect">Specifies whether or not to open the connection</param> 
    public InventoryConnectionContext(string connectString, bool connect = true) 
     : base(connectString) 
    { 
     if (connect) 
      Connect(); 
    } 
} 

回答

0

它們在實體.edmx文件下的動態生成的項目,你把它們。它似乎遵循這種格式*(nameofdb)*實體,是一個實例化類。

爲了得到這個,你需要刪除EntityFrameWork,MySQL.Data,MySQL.Data.Entities NuGets,然後拉你的服務器。你可以通過點擊View-> Server Explorer然後右鍵點擊SharePoint Connections(可能會略有不同),並以這種方式添加您的服務器。然後您可以導入所有表格和實體。它們將顯示在.tt文件下,並且也是自動生成的可實例化類。所有這些都可以通過知道你需要一個上下文和一個實體來修改數據庫一起工作。 [上下文] [表]。新增/刪除。示例context.test_table.Add(myEntity);

; tldr:添加服務器,它在.edmx文件下顯示爲.context.tt,其下的類爲.context.tt。