-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to specify a target migration in Migrate call Warn on Migrate when there are pending model changes Fixes #17568 Fixes #33732 Fixes #34196
- Loading branch information
1 parent
27ca389
commit 84ebd38
Showing
24 changed files
with
576 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
/// <summary> | ||
/// A class that holds the results from the last migrations application. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-migrations">Database migrations</see> for more information and examples. | ||
/// </remarks> | ||
public interface IMigratorData | ||
{ | ||
/// <summary> | ||
/// The migrations that were applied to the database. | ||
/// </summary> | ||
public IReadOnlyList<Migration> AppliedMigrations { get; } | ||
|
||
/// <summary> | ||
/// The migrations that were reverted from the database. | ||
/// </summary> | ||
public IReadOnlyList<Migration> RevertedMigrations { get; } | ||
|
||
/// <summary> | ||
/// The target migration. | ||
/// <see langword="null" /> if all migrations were reverted or no target migration was specified. | ||
/// </summary> | ||
public Migration? TargetMigration { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
/// <summary> | ||
/// <para> | ||
/// A service on the EF internal service provider that allows providers or extensions to execute logic | ||
/// after <see cref="IMigrator.Migrate(string?, Action{DbContext, IMigratorData}?, TimeSpan?)"/> is called. | ||
/// </para> | ||
/// <para> | ||
/// This type is typically used by providers or extensions. It is generally not used in application code. | ||
/// </para> | ||
/// </summary> | ||
/// <remarks> | ||
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance | ||
/// is used by many <see cref="DbContext" /> instances. The implementation must be thread-safe. | ||
/// This service cannot depend on services registered as <see cref="ServiceLifetime.Scoped" />. | ||
/// </remarks> | ||
public interface IMigratorPlugin | ||
{ | ||
/// <summary> | ||
/// Called by <see cref="IMigrator.Migrate(string?, Action{DbContext, IMigratorData}?, TimeSpan?)"/> before the seeding action. | ||
/// </summary> | ||
/// <param name="context">The <see cref="DbContext" /> that is being migrated.</param> | ||
/// <param name="data">The <see cref="IMigratorData" /> that contains the result of the migrations application.</param> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-migrations">Database migrations</see> for more information and examples. | ||
/// </remarks> | ||
void Migrated(DbContext context, IMigratorData data); | ||
|
||
/// <summary> | ||
/// Called by <see cref="IMigrator.MigrateAsync(string?, Func{DbContext, IMigratorData, CancellationToken, Task}?, TimeSpan?, CancellationToken)"/> before the seeding action. | ||
/// </summary> | ||
/// <param name="context">The <see cref="DbContext" /> that is being migrated.</param> | ||
/// <param name="data">The <see cref="IMigratorData" /> that contains the result of the migrations application.</param> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-migrations">Database migrations</see> for more information and examples. | ||
/// </remarks> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken" /> to observe while waiting for the task to complete.</param> | ||
/// <returns>A task that represents the asynchronous operation</returns> | ||
/// <exception cref="OperationCanceledException">If the <see cref="CancellationToken" /> is canceled.</exception> | ||
Task MigratedAsync( | ||
DbContext context, | ||
IMigratorData data, | ||
CancellationToken cancellationToken = default); | ||
} |
Oops, something went wrong.