Share via


DbConfigurationTypeAttribute 类

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

可将此属性置于 DbContext 的子类上,以指示 DbConfiguration 的子类,后者表示应用程序的基于代码的配置与上下文类型处于不同的程序集中。

继承层次结构

System.Object
  System.Attribute
    System.Data.Entity.DbConfigurationTypeAttribute

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

语法

声明
<SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")> _
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False)> _
<SuppressMessageAttribute("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")> _
Public Class DbConfigurationTypeAttribute _
    Inherits Attribute
用法
Dim instance As DbConfigurationTypeAttribute
[SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)]
[SuppressMessageAttribute("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
public class DbConfigurationTypeAttribute : Attribute
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1019:DefineAccessorsForAttributeArguments")]
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false)]
[SuppressMessageAttribute(L"Microsoft.Performance", L"CA1813:AvoidUnsealedAttributes")]
public ref class DbConfigurationTypeAttribute : public Attribute
[<SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)>]
[<SuppressMessageAttribute("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")>]
type DbConfigurationTypeAttribute =  
    class 
        inherit Attribute 
    end
public class DbConfigurationTypeAttribute extends Attribute

DbConfigurationTypeAttribute 类型公开以下成员。

构造函数

  名称 描述
公共方法 DbConfigurationTypeAttribute(String) 指示应对此应用程序的基于代码的配置使用由给定程序集限定名称表示的 DbConfiguration 的子类。
公共方法 DbConfigurationTypeAttribute(Type) 指示应对此应用程序的基于代码的配置使用 DbConfiguration 的给定子类。

顶部

属性

  名称 描述
公共属性 ConfigurationType 获取应对此应用程序的基于代码的配置使用的 DbConfiguration 的子类。
公共属性 TypeId (继承自 Attribute。)

顶部

方法

  名称 描述
公共方法 Equals (继承自 Attribute。)
受保护的方法 Finalize (继承自 Object。)
公共方法 GetHashCode (继承自 Attribute。)
公共方法 GetType (继承自 Object。)
公共方法 IsDefaultAttribute (继承自 Attribute。)
公共方法 Match (继承自 Attribute。)
受保护的方法 MemberwiseClone (继承自 Object。)
公共方法 ToString (继承自 Object。)

顶部

显式接口实现  

  名称 描述
显式接口实现私有方法 _Attribute.GetIDsOfNames (继承自 Attribute。)
显式接口实现私有方法 _Attribute.GetTypeInfo (继承自 Attribute。)
显式接口实现私有方法 _Attribute.GetTypeInfoCount (继承自 Attribute。)
显式接口实现私有方法 _Attribute.Invoke (继承自 Attribute。)

顶部

备注

通常,应将 DbConfiguration 的子类与应用程序使用的 DbContext 的子类置于同一程序集中。 然后,将自动发现它。 但是,如果这不可行或者应用程序在不同程序集中包含多个上下文类型,则可以使用此属性将 DbConfiguration 发现定向到相应类型。 作为代替使用此属性的一种方法,也可以指定要在应用程序的配置文件中使用的 DbConfiguration 类型。 有关更多信息,请参见 https://go.microsoft.com/fwlink/?LinkId=260883。

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参阅

参考

System.Data.Entity 命名空间