Skip to content
Docs Try Aspire
Docs Try

EFResourceBuilderExtensions Methods

Class Methods 4 members
Provides extension methods for adding EF Core migration management to projects.
AddEFMigrations(IResourceBuilder<ProjectResource>, string, string) Section titled AddEFMigrations(IResourceBuilder<ProjectResource>, string, string) extension IResourceBuilder<EFMigrationResource>
Adds EF Core migration management for a specific DbContext type identified by name.
public static class EFResourceBuilderExtensions
{
public static IResourceBuilder<EFMigrationResource> AddEFMigrations(
this IResourceBuilder<ProjectResource> builder,
string name,
string dbContextTypeName)
{
// ...
}
}
builder IResourceBuilder<ProjectResource> The resource builder for the project.
name string The name of the migration resource.
dbContextTypeName string The fully qualified name of the DbContext type to manage migrations for.
IResourceBuilder<EFMigrationResource> An EF migration resource builder for chaining additional configuration.
InvalidOperationException Thrown if migrations for this context type have already been added.

Multiple calls to this method with different context types are supported, allowing you to manage migrations for multiple DbContexts in the same project.

This overload is useful when the DbContext type is not available at compile time, such as when using runtime-discovered context types.

AddEFMigrations(IResourceBuilder<ProjectResource>, string, string, Action<IResourceBuilder<DotnetToolResource>>) Section titled AddEFMigrations(IResourceBuilder<ProjectResource>, string, string, Action<IResourceBuilder<DotnetToolResource>>) extension IResourceBuilder<EFMigrationResource>
Adds EF Core migration management for a specific DbContext type identified by name.
public static class EFResourceBuilderExtensions
{
public static IResourceBuilder<EFMigrationResource> AddEFMigrations(
this IResourceBuilder<ProjectResource> builder,
string name,
string dbContextTypeName,
Action<IResourceBuilder<DotnetToolResource>>? configureToolResource)
{
// ...
}
}
builder IResourceBuilder<ProjectResource> The resource builder for the project.
name string The name of the migration resource.
dbContextTypeName string The fully qualified name of the DbContext type to manage migrations for.
configureToolResource Action<IResourceBuilder<DotnetToolResource>> Optional callback to configure the dotnet-ef tool resource used for migrations.
IResourceBuilder<EFMigrationResource> An EF migration resource builder for chaining additional configuration.
InvalidOperationException Thrown if migrations for this context type have already been added.

Multiple calls to this method with different context types are supported, allowing you to manage migrations for multiple DbContexts in the same project.

This overload is useful when the DbContext type is not available at compile time, such as when using runtime-discovered context types.

AddEFMigrations(IResourceBuilder<ProjectResource>, string) Section titled AddEFMigrations(IResourceBuilder<ProjectResource>, string) extension IResourceBuilder<EFMigrationResource>
Adds EF Core migration management for auto-detected DbContext types.
public static class EFResourceBuilderExtensions
{
public static IResourceBuilder<EFMigrationResource> AddEFMigrations(
this IResourceBuilder<ProjectResource> builder,
string name)
{
// ...
}
}
builder IResourceBuilder<ProjectResource> The resource builder for the project.
name string The name of the migration resource.
IResourceBuilder<EFMigrationResource> An EF migration resource builder for chaining additional configuration.
AddEFMigrations(IResourceBuilder<ProjectResource>, string, Action<IResourceBuilder<DotnetToolResource>>) Section titled AddEFMigrations(IResourceBuilder<ProjectResource>, string, Action<IResourceBuilder<DotnetToolResource>>) extension IResourceBuilder<EFMigrationResource>
Adds EF Core migration management for auto-detected DbContext types.
public static class EFResourceBuilderExtensions
{
public static IResourceBuilder<EFMigrationResource> AddEFMigrations(
this IResourceBuilder<ProjectResource> builder,
string name,
Action<IResourceBuilder<DotnetToolResource>>? configureToolResource)
{
// ...
}
}
builder IResourceBuilder<ProjectResource> The resource builder for the project.
name string The name of the migration resource.
configureToolResource Action<IResourceBuilder<DotnetToolResource>> Optional callback to configure the dotnet-ef tool resource used for migrations.
IResourceBuilder<EFMigrationResource> An EF migration resource builder for chaining additional configuration.