# PublishAsMigrationBundle

- Module: [Aspire.Hosting.EntityFrameworkCore](/reference/api/go/aspire.hosting.entityframeworkcore.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`
- Defined on: [`EFMigrationResource`](/reference/api/go/aspire.hosting.entityframeworkcore/efmigrationresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Configures the EF migration resource to generate a migration bundle during publishing.

## Remarks

During `aspire publish`, the bundle executable is written to the publish output directory
under the `efmigrations` folder. When `publishContainer` is
`true`, Aspire also generates a `Dockerfile` that packages the bundle into
a container image; the container reads the connection string from a
`ConnectionStrings__<name>` environment variable injected automatically for a
`IResourceWithConnectionString` that the migration resource references or waits on.
The startup project (the project on which `AddEFMigrations` was invoked) and the
migrations project (configured via `WithMigrationsProject`
or `WithMigrationsProject`, if
different) must both list the target runtime in their `<RuntimeIdentifiers>` MSBuild property.
If `publishContainer` = `true`, by default this means
adding at minimum `<RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>` to
both projects.

## Definition

```go
func (EFMigrationResource) PublishAsMigrationBundle(options ...*PublishAsMigrationBundleOptions) EFMigrationResource
```

## Parameters

- `options` (`...*PublishAsMigrationBundleOptions`) -- optional settings, see [Options](#options)

## Options

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

- `TargetRuntime` (`*string`) -- The 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` (`*bool`) -- If `true`, creates a self-contained bundle that includes the .NET runtime.
- `PublishContainer` (`*bool`) -- If `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` (`*string`) -- Overrides 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`.

## Returns

[`EFMigrationResource`](/reference/api/go/aspire.hosting.entityframeworkcore/efmigrationresource.md) -- The resource builder for chaining.

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

## Applies to

- [`EFMigrationResource`](/reference/api/go/aspire.hosting.entityframeworkcore/efmigrationresource.md)
