Describe the issue or suggestion
In ef-core-migrations.md, there are some codes has runtime error!
After creating a MigrationsService and Worker.cs,just like:
private static async Task RunMigrationAsync(CommandDbContext dbContext, CancellationToken cancellationToken)
{
var strategy = dbContext.Database.CreateExecutionStrategy();
await strategy.ExecuteAsync(async () =>
{
// Run migration in a transaction to avoid partial migration if it fails.
await using var transaction = await dbContext.Database.BeginTransactionAsync(cancellationToken);
await dbContext.Database.MigrateAsync(cancellationToken);
await transaction.CommitAsync(cancellationToken);
});
}
Afte running AspireHost, I got an error: User transaction is not supported with a TransactionSuppressed migrations or a retrying execution strategy.
So why use transaction?