Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

EFMigrationResource

Handle
📦 Aspire.Hosting.EntityFrameworkCore v17.0.0-preview.1.26565.2

Represents an EF Core migration resource associated with a project.

type EFMigrationResource interface {
IComputeResource
Resource
ResourceWithArgs
ResourceWithEndpoints
ResourceWithEnvironment
ResourceWithWaitSupport
}

Properties

propertyBundleBaseImage*stringget · set
Gets or sets the base container image for the migration bundle container.
BundleBaseImage() (*string, error)
SetBundleBaseImage(value *string) EFMigrationResource
propertyBundleSelfContainedboolget · set
Gets or sets whether the migration bundle should be self-contained.
BundleSelfContained() (bool, error)
SetBundleSelfContained(value bool) EFMigrationResource
propertyBundleTargetRuntime*stringget · set
Gets or sets the target runtime identifier for the migration bundle (e.g., "linux-x64", "win-x64").
BundleTargetRuntime() (*string, error)
SetBundleTargetRuntime(value *string) EFMigrationResource
propertyDbContextTypeName*stringget
Gets the fully qualified name of the DbContext type to use for migrations, or null to auto-detect.
DbContextTypeName() (*string, error)
propertyMigrationNamespace*stringget · set
Gets or sets the namespace for new migrations. Used by the Add Migration command.
MigrationNamespace() (*string, error)
SetMigrationNamespace(value *string) EFMigrationResource
propertyMigrationOutputDirectory*stringget · set
Gets or sets the output directory for new migrations. Used by the Add Migration command.
MigrationOutputDirectory() (*string, error)
SetMigrationOutputDirectory(value *string) EFMigrationResource
propertyMigrationsProjectPath*stringget · set
Gets or sets the path to the project containing the migrations, when it's not the same as the startup project.
MigrationsProjectPath() (*string, error)
SetMigrationsProjectPath(value *string) EFMigrationResource
propertyProjectResourceProjectResourceget
Gets the parent project resource that contains the DbContext.
ProjectResource() ProjectResource
propertyPublishBundleContainerboolget · set
Gets or sets whether the migration bundle should be published as a container image that applies the migrations to the database at deploy time.
PublishBundleContainer() (bool, error)
SetPublishBundleContainer(value bool) EFMigrationResource
propertyResourceTypeDisplayNamestringget
Gets the ResourceTypeDisplayName property
ResourceTypeDisplayName() (string, error)
propertyScriptIdempotentboolget · set
Gets or sets whether the migration script should be idempotent (include IF NOT EXISTS checks).
ScriptIdempotent() (bool, error)
SetScriptIdempotent(value bool) EFMigrationResource
propertyScriptNoTransactionsboolget · set
Gets or sets whether to omit transaction statements from the migration script.
ScriptNoTransactions() (bool, error)
SetScriptNoTransactions(value bool) EFMigrationResource
propertyStartupProjectResourceDotnetProgramResourceget
Gets the startup .NET program resource that contains the DbContext configuration.
StartupProjectResource() DotnetProgramResource

Methods

Configures the EF migration resource to generate a migration bundle during publishing.
PublishAsMigrationBundle(options ...*PublishAsMigrationBundleOptions) EFMigrationResource
options...*PublishAsMigrationBundleOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*PublishAsMigrationBundleOptions argument.

TargetRuntime*stringThe target runtime identifier for the bundle (e.g., linux-x64, win-x64). If null and publishContainer is true, defaults to linux-x64 to match the default Linux base container image used for the generated Dockerfile. If null and publishContainer is false, the bundle targets the runtime hosting aspire publish.
SelfContained*boolIf true, creates a self-contained bundle that includes the .NET runtime.
PublishContainer*boolIf true, the bundle is published as a container image that applies migrations at deploy time. The resource becomes a compute resource; each target environment deploys it the same way it deploys any other container (supplying connection strings from referenced IResourceWithConnectionString dependencies via the standard WithReference mechanism).
BaseImage*stringOverrides the base container image for the generated Dockerfile. When null (the default), the image is derived from the project's target framework — for example, mcr.microsoft.com/dotnet/runtime:10.0 for a net10.0 framework-dependent bundle. Set this when the default is not suitable, e.g. for preview SDKs or custom base images. Only meaningful when publishContainer is true.
EFMigrationResource

The resource builder for chaining.

Returns a handle; failures surface later via Err().

Configures the EF migration resource to generate a migration script during publishing.
PublishAsMigrationScript(options ...*PublishAsMigrationScriptOptions) EFMigrationResource
options...*PublishAsMigrationScriptOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*PublishAsMigrationScriptOptions argument.

Idempotent*boolIf true (the default), generates an idempotent script with IF NOT EXISTS checks so it can be safely re-run against a database that has already had some or all of the migrations applied.
NoTransactions*boolIf true, omits transaction statements from the script.
EFMigrationResource

The resource builder for chaining.

Returns a handle; failures surface later via Err().

Configures the EF migration resource to run database update when the AppHost starts.
RunDatabaseUpdateOnStart() EFMigrationResource
EFMigrationResource

The resource builder for chaining.

Returns a handle; failures surface later via Err().

Configures the namespace for new migrations created with the Add Migration command.
WithMigrationNamespace(namespace string) EFMigrationResource
namespacestringThe namespace for generated migrations.
EFMigrationResource

The resource builder for chaining.

Returns a handle; failures surface later via Err().

Configures the output directory for new migrations created with the Add Migration command.
WithMigrationOutputDirectory(outputDirectory string) EFMigrationResource
outputDirectorystringThe output directory path relative to the project root.
EFMigrationResource

The resource builder for chaining.

Returns a handle; failures surface later via Err().

Configures a separate project containing migrations for polyglot AppHosts.
WithMigrationsProject(options ...*WithMigrationsProjectOptions) EFMigrationResource
options...*WithMigrationsProjectOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithMigrationsProjectOptions argument.

MigrationsProjectany
EFMigrationResource

Returns a handle; failures surface later via Err().