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

How do intercept annotations? #1210

Closed
weitzhandler opened this issue Dec 31, 2018 — with docs.microsoft.com · 2 comments
Closed

How do intercept annotations? #1210

weitzhandler opened this issue Dec 31, 2018 — with docs.microsoft.com · 2 comments

Comments

Copy link
Contributor

Hi,

I set up my model adding custom annotations to some entities with the fluent API in the OnModelCreating call.
How can I intercept this data when generating the tables when overriding the Generate methods?

Please see this issue: #1203


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@weitzhandler
Copy link
Contributor Author

weitzhandler commented Dec 31, 2018

Ok got it

protected override void Generate(CreateTableOperation operation, IModel model, 
  MigrationCommandListBuilder builder)
{
  var entity = model.GetEntityTypes().Single(et => et.Relational().TableName == operation.Name);
  var annotations = entity.GetAnnotations().Where(an => an.Name.StartsWith(myAnnotationScope));
  // do my stuff
}

But it would be nice to have it documented somewhere, @divega @AndriySvyryd.

@pcopley
Copy link

pcopley commented May 24, 2019

Is it possible to do this if you are overriding Generate with the base MigrationOperation? I would like to be able to get the entity and their annotations for all operations not just CreateTable.

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

No branches or pull requests

2 participants