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

Add documentation for pre-convention model configuration #3533

Merged
merged 1 commit into from
Dec 6, 2021

Conversation

AndriySvyryd
Copy link
Member

@AndriySvyryd AndriySvyryd commented Nov 5, 2021

Part of #3278
Fixes #571

entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
### Drawbacks of the Metadata API

- Unlike Fluent API, every modification to the model needs to be done explicitly. For example, if some of the `Money` properties were configured as navigations by a convention then you need to first remove the navigation referencing the CLR property before adding an entity type property for it. [#9117](https://github.com/dotnet/efcore/issues/9117) will improve this.
- The conventions run after each change. If you remove a navigation discovered by a convention then the convention will run again and add it back. To prevent this from happening you would need to either delay the conventions until after the property is added by calling <xref:Microsoft.EntityFrameworkCore.Metadata.Conventions.IConventionContext.DelayConventions> or to mark the CLR property as ignored using <xref:Microsoft.EntityFrameworkCore.Metadata.IMutableModel.AddIgnored%2A>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt many would understand what this means 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem, the solution or both?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both. To be clear, this isn't about your text or anything - it's just that understanding the reactivity of conventions and what that could mean is a very advanced, internal thing.

Maybe it's better to go with something vague, just to convey the "unreliability" of this mechanism (e.g. "Some changes done via the Fluent API may not result in the desired results. For example, if you remove a navigation discovered by a convention, then that convention will run again and add it back."). Otherwise we could go with this too - I just doubt it would help many people.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll expand and move this in #1937

entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
entity-framework/core/modeling/bulk-configuration.md Outdated Show resolved Hide resolved
@AndriySvyryd AndriySvyryd changed the title Add documentation for pre-convention model configuration Add documentation for pre-convention model configuration Dec 6, 2021
@AndriySvyryd AndriySvyryd merged commit 64cf3ac into main Dec 6, 2021
@AndriySvyryd AndriySvyryd deleted the Issue3278 branch December 6, 2021 20:24
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

Successfully merging this pull request may close these issues.

Bulk configuring models
3 participants