Skip to content

Add Migration name check - #26396

Merged
AndriySvyryd merged 4 commits into
dotnet:mainfrom
KevRitchie:Migration-Name-Filter
May 19, 2022
Merged

AndriySvyryd merged 4 commits into
dotnet:mainfrom
KevRitchie:Migration-Name-Filter

Conversation

@KevRitchie

Copy link
Copy Markdown
Contributor

Summary of the changes:

  • Add a check during the Validate method of MigrationsAddCommand to throw a CommandException when someone tries to call their migration "migration".
  • Add a new resource "CircularBaseClassDependency" to notify the user that "You cannot add a migration with the name 'Migration'".

Fixes #23222

@KevRitchie

Copy link
Copy Markdown
Contributor Author

Hi @bricelam, does this look OK? Is there anything else I need to consider?

@bricelam

bricelam commented Oct 26, 2021 •

Copy link
Copy Markdown
Contributor

This check should probably be a bit deeper into the internals to handle scenarios outside of the CLI and PMC tools. Probably here:

Check.NotEmpty(migrationName, nameof(migrationName));
if (Dependencies.MigrationsAssembly.FindMigrationId(migrationName) != null)
{
throw new OperationException(DesignStrings.DuplicateMigrationName(migrationName));
}

@KevRitchie

Copy link
Copy Markdown
Contributor Author

Thanks. I'll take a look 👍

Comment thread src/ef/Commands/MigrationsAddCommand.cs Resolved
Comment thread src/ef/Properties/Resources.resx Resolved
@KevRitchie
KevRitchie requested a review from bricelam February 23, 2022 14:56

@bricelam bricelam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndriySvyryd

Copy link
Copy Markdown
Member

@bricelam Is there anything preventing this from being checked in apart from the conflict?

@bricelam

Copy link
Copy Markdown
Contributor

Nope, good to merge.

@AndriySvyryd

Copy link
Copy Markdown
Member

Thanks for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration name filter

4 participants