Skip to content

Commit

Permalink
Clean up PR dotnet#31164
Browse files Browse the repository at this point in the history
  • Loading branch information
bricelam committed Jul 18, 2023
1 parent 20372c5 commit 43aeb62
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/EFCore.Design/Design/Internal/MigrationsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public virtual MigrationFiles RemoveMigration(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void CheckPendingMigrations(string? contextType)
public virtual void HasPendingModelChanges(string? contextType)
{
using var context = _contextOperations.CreateContext(contextType);

Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.Design/Design/OperationExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,10 @@ private string ScriptDbContextImpl(string? contextType)
/// <summary>
/// Represents an operation to check if there are any pending migrations.
/// </summary>
public class CheckPendingMigrations : OperationBase
public class HasPendingModelChanges : OperationBase
{
/// <summary>
/// Initializes a new instance of the <see cref="CheckPendingMigrations" /> class.
/// Initializes a new instance of the <see cref="HasPendingModelChanges" /> class.
/// </summary>
/// <remarks>
/// <para>The arguments supported by <paramref name="args" /> are:</para>
Expand All @@ -698,7 +698,7 @@ public class CheckPendingMigrations : OperationBase
/// <param name="executor">The operation executor.</param>
/// <param name="resultHandler">The <see cref="IOperationResultHandler" />.</param>
/// <param name="args">The operation arguments.</param>
public CheckPendingMigrations(
public HasPendingModelChanges(
OperationExecutor executor,
IOperationResultHandler resultHandler,
IDictionary args)
Expand All @@ -709,12 +709,12 @@ public CheckPendingMigrations(

var contextType = (string?)args["contextType"];

Execute(() => executor.CheckPendingMigrationsImpl(contextType));
Execute(() => executor.HasPendingModelChangesImpl(contextType));
}
}

private void CheckPendingMigrationsImpl(string? contextType)
=> MigrationsOperations.CheckPendingMigrations(contextType);
private void HasPendingModelChangesImpl(string? contextType)
=> MigrationsOperations.HasPendingModelChanges(contextType);


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ public static bool IsRelational(this DatabaseFacade databaseFacade)
/// <summary>
/// Returns <see langword="true" /> if the model has pending changes to be applied.
/// </summary>
/// <param name="databaseFacade">Tbe facade from <see cref="DbContext.Database"/>.</param>
/// <param name="databaseFacade">The facade from <see cref="DbContext.Database"/>.</param>
/// <returns>
/// <see langword="true"/> if the database model has pending changes.
/// <see langword="false"/> if a new migration has to be added.
Expand Down
2 changes: 1 addition & 1 deletion src/ef/Commands/MigrationsHasPendingModelChangesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ protected override int Execute(string[] args)
{
using var executor = CreateExecutor(args);

executor.CheckPendingMigrations(Context!.Value());
executor.HasPendingModelChanges(Context!.Value());

return base.Execute(args);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ef/IOperationExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ IDictionary ScaffoldContext(
string ScriptMigration(string? fromMigration, string? toMigration, bool idempotent, bool noTransactions, string? contextType);

string ScriptDbContext(string? contextType);
void CheckPendingMigrations(string? contextType);
void HasPendingModelChanges(string? contextType);
}
4 changes: 2 additions & 2 deletions src/ef/OperationExecutorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ public string ScriptDbContext(string? contextType)
"ScriptDbContext",
new Dictionary<string, object?> { ["contextType"] = contextType });

public void CheckPendingMigrations(string? contextType)
public void HasPendingModelChanges(string? contextType)
=> InvokeOperation<string>(
"CheckPendingMigrations",
"HasPendingModelChanges",
new Dictionary<string, object?> { ["contextType"] = contextType });
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Transactions;
using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal;
using Microsoft.EntityFrameworkCore.TestModels.UpdatesModel;
using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider;
using IsolationLevel = System.Data.IsolationLevel;

Expand Down Expand Up @@ -275,14 +274,11 @@ public void HasPendingModelChanges_has_migrations_and_no_new_context_changes_ret
{
var fakeModelSnapshot = new FakeModelSnapshot(builder =>
{
// TODO: This seems fragile, what should I do?
builder.HasAnnotation("ProductVersion", "8.0.0-dev");

builder.Entity("Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensionsTests.TestDbContext.Simple", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("default_int_mapping");

b.HasKey("Id");

Expand All @@ -291,7 +287,7 @@ public void HasPendingModelChanges_has_migrations_and_no_new_context_changes_ret
});
var migrationsAssembly = new FakeIMigrationsAssembly
{
ModelSnapshot = null,
ModelSnapshot = fakeModelSnapshot,
Migrations = new Dictionary<string, TypeInfo>(),
};

Expand All @@ -302,7 +298,7 @@ public void HasPendingModelChanges_has_migrations_and_no_new_context_changes_ret

var testContext = new TestDbContext(contextOptions);

Assert.True(testContext.Database.HasPendingModelChanges());
Assert.False(testContext.Database.HasPendingModelChanges());
}

private class TestDbContext : DbContext
Expand Down

0 comments on commit 43aeb62

Please sign in to comment.