Share 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
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

Product Versions
Entity Framework Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0