Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations: Provider-rendered annotations in code #6546

Open
Tracked by #22946
bricelam opened this issue Sep 15, 2016 · 5 comments
Open
Tracked by #22946

Migrations: Provider-rendered annotations in code #6546

bricelam opened this issue Sep 15, 2016 · 5 comments

Comments

@bricelam
Copy link
Contributor

bricelam commented Sep 15, 2016

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.

@bricelam bricelam changed the title Migrations: Provider rendered-annotations in code Migrations: Provider-rendered annotations in code Sep 16, 2016
@roji
Copy link
Member

roji commented Sep 16, 2016

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.

@bricelam
Copy link
Contributor Author

bricelam commented Sep 16, 2016

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().

@roji
Copy link
Member

roji commented Mar 19, 2021

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

@roji roji removed this from the Backlog milestone Mar 19, 2021
@ajcvickers
Copy link
Member

/cc @bricelam

@bricelam
Copy link
Contributor Author

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

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

No branches or pull requests

6 participants