Skip to content

Append timestamp to scaffolded migration type names #36066

@roji

Description

@roji

When a new migration is added, EF currently scaffolds a .NET type with the name of the migration. This leads to a variety of issues around the name being problematic in C#:

  • The type name happens to be the same as a .NET type. A very frequent case is when users do dotnet ef migrations add DateTime.
  • The C# compiler now raises warnings when a type name could conflict with a future keyword (i.e. all-lowercase name), see #35938.

Migration files already have their creation timestamp prefixed to the name, so that migrations are properly sorted on the filesystem. We can simply append the same timestamp to the type name inside: public class DateTime_20250512080000 {...}.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions