Class UmbracoDbContext
Inheritance
System.Object
Namespace: Umbraco.Cms.Persistence.EFCore
Assembly: Umbraco.Cms.Persistence.EFCore.dll
Syntax
public class UmbracoDbContext : DbContext
Remarks
To autogenerate migrations use the following commands and insure the 'src/Umbraco.Web.UI/appsettings.json' have a connection string set with the right provider.
Create a migration for each provider.
dotnet ef migrations add %Name% -s src/Umbraco.Web.UI -p src/Umbraco.Cms.Persistence.EFCore.SqlServer -- --provider SqlServer
dotnet ef migrations add %Name% -s src/Umbraco.Web.UI -p src/Umbraco.Cms.Persistence.EFCore.Sqlite -- --provider Sqlite
Remove the last migration for each provider.
dotnet ef migrations remove -s src/Umbraco.Web.UI -p src/Umbraco.Cms.Persistence.EFCore.SqlServer -- --provider SqlServer
dotnet ef migrations remove -s src/Umbraco.Web.UI -p src/Umbraco.Cms.Persistence.EFCore.Sqlite -- --provider Sqlite
To find documentation about this way of working with the context see https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/providers?tabs=dotnet-core-cli#using-one-context-type
Constructors
View SourceUmbracoDbContext(DbContextOptions<UmbracoDbContext>)
Initializes a new instance of the UmbracoDbContext class.
Declaration
public UmbracoDbContext(DbContextOptions<UmbracoDbContext> options)
Parameters
Type | Name | Description |
---|---|---|
DbContextOptions<UmbracoDbContext> | options |
Methods
View SourceOnModelCreating(ModelBuilder)
Declaration
protected override void OnModelCreating(ModelBuilder modelBuilder)
Parameters
Type | Name | Description |
---|---|---|
ModelBuilder | modelBuilder |