Skip to content

Migrations: Provider-rendered annotations in code #6546

Description

@bricelam

This was part of #1825, but I'm splitting it out so we can prioritize it separately.

Currently, annotations on migration operations (and in the model snapshot) are rendered generally by the code generator:

migrationBuilder.AddColumn<int>(
    name: "Id",
    table: "Person")
    .Annotation(
        "SqlServer:ValueGenerationStrategy",
        SqlServerValueGenerationStrategy.IdentityColumn);

Similar to how relational annotations are handled when scaffolding the model snapshot, providers should be given an opportunity to render these annotations to provider-specific extension methods. For example:

migrationBuilder.AddColumn<int>(
    name: "Id",
    table: "Person")
    .UseSqlServerIdentityColumn();

If a provider cannot render the annotation for the current language, the original syntax will be used as a fallback.

Activity

  1. changed the title [-]Migrations: Provider rendered-annotations in code[/-] [+]Migrations: Provider-rendered annotations in code[/+] on Sep 16, 2016
  2. roji commented on Sep 16, 2016

    @roji
    Member

    Whatever mechanism the provider will have to specify its own rendering to annotations in migrations, note the importance of passing it the old annotation value in addition to the new. This is necessary to support more advanced scenario where structured data is represented in the annotation value, e.g. a list of PostgreSQL extensions.

  3. bricelam commented on Sep 16, 2016

    @bricelam
    ContributorAuthor

    Yes, AlterDatabase, AlterSequence, AlterTable, and AlterColumn have both the new and old annotation values. Drop operations will also have any old annotations provided by IMigrationsAnnotationProvider.ForRemove().

  4. added this to the Backlog milestone on Sep 21, 2016
  5. roji commented on Mar 19, 2021

    @roji
    Member

    Wasn't this done in #21329 (there wasn't really a tracking issue aside from #16922)?

  6. removed this from the Backlog milestone on Mar 19, 2021
  7. ajcvickers commented on Mar 19, 2021

    @ajcvickers
    Contributor
  8. bricelam commented on Mar 19, 2021

    @bricelam
    ContributorAuthor

    No, this is about annotations inside the Up and Down methods--not the snapshot.

  9. added this to the Backlog milestone on Mar 20, 2021
  10. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions