2013-11-14 97 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。