Use migration ID as scaffolded migration type name#37841
Merged
AndriySvyryd merged 5 commits intomainfrom Mar 4, 2026
Merged
Conversation
When scaffolding a new migration, the type name now includes the timestamp from the migration ID. For example, a migration named "DateTime" will generate a type named "DateTime_20250512080000" instead of just "DateTime", avoiding conflicts with .NET types and potential C# keyword warnings. Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Append timestamp to scaffolded migration type names
Append timestamp to scaffolded migration type names
Mar 4, 2026
AndriySvyryd
reviewed
Mar 4, 2026
AndriySvyryd
reviewed
Mar 4, 2026
Simplify by passing the migration ID directly as the type name instead of constructing Name_Timestamp. The Code.Identifier() call in the code generator handles making it a valid C# identifier. Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates migration scaffolding to avoid generated migration type names colliding with BCL types / triggering compiler warnings by appending the migration timestamp (already present in the migration ID / file name) to the generated class name.
Changes:
- Derive
migrationTypeNameby appending the timestamp portion ofmigrationIdand pass it toGenerateMigration/GenerateMetadata. - Add a design-time test asserting the timestamped type name appears in both the migration and metadata output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/EFCore.Design/Migrations/Design/MigrationsScaffolder.cs | Appends migration ID timestamp to the generated migration type name when scaffolding. |
| test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs | Adds test coverage ensuring generated code contains the timestamped type name and the original [Migration] attribute. |
You can also share your feedback on Copilot code review. Take the survey.
Copilot
AI
changed the title
Append timestamp to scaffolded migration type names
Use migration ID as scaffolded migration type name
Mar 4, 2026
Update expected type names in OperationExecutorTest and HierarchyId MigrationTests to reflect migration ID being used as the type name (prefixed with _ since IDs start with a digit). Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Member
|
@ErikEJ FYI |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
…Test.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
roji
approved these changes
Mar 4, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MigrationsScaffolder.ScaffoldMigrationto use migration ID as the type nameMigrationsScaffolderTestto verify the type name in scaffolded codeOperationExecutorTestexpected code templates to use migration ID-based type nameMigrationTestsexpected code templates to use migration ID-based type nameOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.