Skip to content
DocsTry Aspire
DocsTry

EFMigrationResource Properties

ClassProperties13 members
Represents an EF Core migration resource associated with a project.
BundleBaseImageSection titled BundleBaseImagenullablestring?
Gets or sets the base container image for the migration bundle container.
public string? BundleBaseImage { get; set; }
When set, this overrides the default base image selection entirely. Use this when the default image (derived from the project's target framework) isn't suitable — for example when targeting a preview SDK or a custom base image with extra dependencies. Example: "mcr.microsoft.com/dotnet/runtime:11.0-preview".
BundleSelfContainedSection titled BundleSelfContainedbool
Gets or sets whether the migration bundle should be self-contained.
public bool BundleSelfContained { get; set; }
BundleTargetRuntimeSection titled BundleTargetRuntimenullablestring?
Gets or sets the target runtime identifier for the migration bundle (e.g., "linux-x64", "win-x64").
public string? BundleTargetRuntime { get; set; }
DbContextTypeNameSection titled DbContextTypeNamenullablestring?
Gets the fully qualified name of the DbContext type to use for migrations, or null to auto-detect.
public string? DbContextTypeName { get; }
This property is used to specify which DbContext to use when the project contains multiple DbContext types. When null, the EF Core tools will auto-detect the DbContext to use.
MigrationNamespaceSection titled MigrationNamespacenullablestring?
Gets or sets the namespace for new migrations. Used by the Add Migration command.
public string? MigrationNamespace { get; set; }
If not specified, the namespace will be derived from the project's default namespace.
MigrationOutputDirectorySection titled MigrationOutputDirectorynullablestring?
Gets or sets the output directory for new migrations. Used by the Add Migration command.
public string? MigrationOutputDirectory { get; set; }
If not specified, migrations will be placed in the default 'Migrations' directory.
MigrationsProjectPathSection titled MigrationsProjectPathnullablestring?
Gets or sets the path to the project containing the migrations, when it's not the same as the startup project.
public string? MigrationsProjectPath { get; set; }
If not specified, migrations are assumed to be in the startup project. When specified, this project's path will be used as the target for migration operations.
ProjectResourceSection titled ProjectResourceProjectResource
Gets the parent project resource that contains the DbContext.
public ProjectResource ProjectResource { get; }
PublishAsMigrationBundleSection titled PublishAsMigrationBundlebool
Gets or sets whether a migration bundle should be generated during publishing.
public bool PublishAsMigrationBundle { get; set; }
PublishAsMigrationScriptSection titled PublishAsMigrationScriptbool
Gets or sets whether a migration script should be generated during publishing.
public bool PublishAsMigrationScript { get; set; }
PublishBundleContainerSection titled PublishBundleContainerbool
Gets or sets whether the migration bundle should be published as a container image that applies the migrations to the database at deploy time.
public bool PublishBundleContainer { get; set; }
When true, the resource is materialized as a ApplicationModel.ContainerResource carrying a generated Dockerfile that wraps the migration bundle. The compute environment (Docker Compose, Azure Container Apps, Kubernetes, Azure App Service, Azure Functions, etc.) deploys it alongside the other compute resources and supplies the connection string from any ApplicationModel.IResourceWithConnectionString dependency declared via WithReference or WaitFor.
Gets or sets whether the migration script should be idempotent (include IF NOT EXISTS checks).
public bool ScriptIdempotent { get; set; }
ScriptNoTransactionsSection titled ScriptNoTransactionsbool
Gets or sets whether to omit transaction statements from the migration script.
public bool ScriptNoTransactions { get; set; }