Partager via


DbContextAttribute Class

Definition

Identifies the DbContext that a class belongs to. For example, this attribute is used to identify which context a migration applies to. It is also used to indicate the contexts used in an assembly for design-time tools.

[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class DbContextAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class, AllowMultiple=true)]
public sealed class DbContextAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type DbContextAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class, AllowMultiple=true)>]
type DbContextAttribute = class
    inherit Attribute
Public NotInheritable Class DbContextAttribute
Inherits Attribute
Inheritance
DbContextAttribute
Attributes

Remarks

See Managing database schemas with EF Core for more information and examples.

Constructors

DbContextAttribute(Type)

Initializes a new instance of the DbContextAttribute class.

Properties

ContextType

Gets the associated context.

Applies to