DbModelBuilderVersionAttribute 类
[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]
此特性可应用于派生自 DbContext 的类,以便在从代码生成模型(也称为“Code First”)时设置应使用的 DbContext 和 DbModelBuilder 约定的版本。 有关 DbModelBuilder 版本的详细信息,请参见 DbModelBuilderVersion 枚举。
继承层次结构
System.Object
System.Attribute
System.Data.Entity.DbModelBuilderVersionAttribute
命名空间: System.Data.Entity
程序集: EntityFramework(在 EntityFramework.dll 中)
语法
声明
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False)> _
Public NotInheritable Class DbModelBuilderVersionAttribute _
Inherits Attribute
用法
Dim instance As DbModelBuilderVersionAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)]
public sealed class DbModelBuilderVersionAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false)]
public ref class DbModelBuilderVersionAttribute sealed : public Attribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)>]
type DbModelBuilderVersionAttribute =
class
inherit Attribute
end
public final class DbModelBuilderVersionAttribute extends Attribute
DbModelBuilderVersionAttribute 类型公开以下成员。
构造函数
名称 | 描述 | |
---|---|---|
DbModelBuilderVersionAttribute | 初始化 DbModelBuilderVersionAttribute 类的新实例。 |
顶部
属性
名称 | 描述 | |
---|---|---|
TypeId | (继承自 Attribute。) | |
Version | 获取 DbModelBuilder 约定版本。 |
顶部
方法
名称 | 描述 | |
---|---|---|
Equals | (继承自 Attribute。) | |
GetHashCode | (继承自 Attribute。) | |
GetType | (继承自 Object。) | |
IsDefaultAttribute | (继承自 Attribute。) | |
Match | (继承自 Attribute。) | |
ToString | (继承自 Object。) |
顶部
显式接口实现
名称 | 描述 | |
---|---|---|
_Attribute.GetIDsOfNames | (继承自 Attribute。) | |
_Attribute.GetTypeInfo | (继承自 Attribute。) | |
_Attribute.GetTypeInfoCount | (继承自 Attribute。) | |
_Attribute.Invoke | (继承自 Attribute。) |
顶部
备注
如果 DbContext 中缺少该特性,则 DbContext 将总是使用约定的最新版本。 这等效于使用 DbModelBuilderVersion.Latest。
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。