Skip to content

Append timestamp to scaffolded migration type names #36066

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 {...}.

Activity

  1. added this to the Backlog milestone on May 12, 2025
  2. modified the milestones: Backlog, 10.0.0 on May 12, 2025
  3. roji commented on May 12, 2025

    @roji
    MemberAuthor

    Tentatively proposing as a stretch goal in 10.

  4. self-assigned this
    on Jun 8, 2025
  5. added theissue type on Jun 15, 2025
  6. modified the milestones: 10.0.0, 11.0.0 on Aug 19, 2025
  7. added a commit that references this issue on Mar 4, 2026
    9bad67c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions