View Source
Class UmbracoEFCoreServiceCollectionExtensions
Assembly: Umbraco.Cms.Persistence.EFCore.dll
Syntax
public static class UmbracoEFCoreServiceCollectionExtensions
Methods
View Source
AddUmbracoDbContext<T>(IServiceCollection, Action<DbContextOptionsBuilder, string?, string?, IServiceProvider?>?)
Adds a EFCore DbContext with all the services needed to integrate with Umbraco scopes.
Declaration
public static IServiceCollection AddUmbracoDbContext<T>(this IServiceCollection services, Action<DbContextOptionsBuilder, string?, string?, IServiceProvider?>? optionsAction = null) where T : DbContext
Parameters
| Type |
Name |
Description |
| IServiceCollection |
services |
|
| Action<DbContextOptionsBuilder, string, string, IServiceProvider> |
optionsAction |
|
Returns
| Type |
Description |
| IServiceCollection |
|
Type Parameters
View Source
AddUmbracoDbContext<T>(IServiceCollection, Action<DbContextOptionsBuilder>?)
Adds a EFCore DbContext with all the services needed to integrate with Umbraco scopes.
Declaration
[Obsolete("Please use the method overload that takes all parameters for the optionsAction. Scheduled for removal in Umbraco 18.")]
public static IServiceCollection AddUmbracoDbContext<T>(this IServiceCollection services, Action<DbContextOptionsBuilder>? optionsAction = null) where T : DbContext
Parameters
| Type |
Name |
Description |
| IServiceCollection |
services |
|
| Action<DbContextOptionsBuilder> |
optionsAction |
|
Returns
| Type |
Description |
| IServiceCollection |
|
Type Parameters
View Source
AddUmbracoDbContext<T>(IServiceCollection, Action<IServiceProvider, DbContextOptionsBuilder, string?, string?>?)
Adds a EFCore DbContext with all the services needed to integrate with Umbraco scopes.
Declaration
public static IServiceCollection AddUmbracoDbContext<T>(this IServiceCollection services, Action<IServiceProvider, DbContextOptionsBuilder, string?, string?>? optionsAction = null) where T : DbContext
Parameters
| Type |
Name |
Description |
| IServiceCollection |
services |
|
| Action<IServiceProvider, DbContextOptionsBuilder, string, string> |
optionsAction |
|
Returns
| Type |
Description |
| IServiceCollection |
|
Type Parameters
View Source
AddUmbracoDbContext<T>(IServiceCollection, Action<IServiceProvider, DbContextOptionsBuilder>?)
Adds a EFCore DbContext with all the services needed to integrate with Umbraco scopes.
Declaration
[Obsolete("Please use the method overload that takes all parameters for the optionsAction. Scheduled for removal in Umbraco 18.")]
public static IServiceCollection AddUmbracoDbContext<T>(this IServiceCollection services, Action<IServiceProvider, DbContextOptionsBuilder>? optionsAction = null) where T : DbContext
Parameters
| Type |
Name |
Description |
| IServiceCollection |
services |
|
| Action<IServiceProvider, DbContextOptionsBuilder> |
optionsAction |
|
Returns
| Type |
Description |
| IServiceCollection |
|
Type Parameters
View Source
UseDatabaseProvider(DbContextOptionsBuilder, string, string)
Sets the database provider. I.E UseSqlite or UseSqlServer based on the provider name.
Declaration
public static void UseDatabaseProvider(this DbContextOptionsBuilder builder, string providerName, string connectionString)
Parameters
| Type |
Name |
Description |
| DbContextOptionsBuilder |
builder |
|
| string |
providerName |
|
| string |
connectionString |
|
Exceptions
| Type |
Condition |
| InvalidDataException |
|
View Source
UseUmbracoDatabaseProvider(DbContextOptionsBuilder, IServiceProvider)
Sets the database provider to use based on the Umbraco connection string.
Declaration
public static void UseUmbracoDatabaseProvider(this DbContextOptionsBuilder builder, IServiceProvider serviceProvider)
Parameters
| Type |
Name |
Description |
| DbContextOptionsBuilder |
builder |
|
| IServiceProvider |
serviceProvider |
|