ObjectContext 构造函数 (String)

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

使用给定连接字符串和默认实体容器名称初始化 ObjectContext 类的新实例。

命名空间:  System.Data.Entity.Core.Objects
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification := "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")> _
Public Sub New ( _
    connectionString As String _
)
用法
Dim connectionString As String 

Dim instance As New ObjectContext(connectionString)
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification = "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")]
public ObjectContext(
    string connectionString
)
[SuppressMessageAttribute(L"Microsoft.Reliability", L"CA2000:DisposeObjectsBeforeLosingScope", Justification = L"Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")]
public:
ObjectContext(
    String^ connectionString
)
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification = "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")>]
new : 
        connectionString:string -> ObjectContext
public function ObjectContext(
    connectionString : String
)

参数

  • connectionString
    类型:System.String
    连接字符串,该连接字符串还提供对元数据信息的访问。

异常

例外 条件
ArgumentNullException

connectionString 为 null。

ArgumentException

connectionString 无效或元数据工作区无效。

请参阅

参考

ObjectContext 类

ObjectContext 重载

System.Data.Entity.Core.Objects 命名空间