Repository navigation
Closed
Copy link
Milestone
Description
- Create public interfaces for metadata API to be used by conventions.
- Change
QueryFilter,DefiningQuery,IsEagerLoaded,IsShadowProperty,IsIndexedProperty,BeforeSaveBehaviorAfterSaveBehaviorto extension methods. - Throw when calling
SetFieldwould change the shadowness of a property or the name of the identifyingMemberInfo. - Rename
GetContainingPrimaryKeytoFindContainingPrimaryKey. - Throw when calling
SetFieldon a shadow or a field-only property. - Create public interfaces that the internal model builders implement, e.g.
IConventionModelBuilder. This will allow cleaner API, without the explicitConfigurationSourceparameter. - Throw instead of silently failing when a non-explicit configuration call is invalid. This would require adding quiz API ('CanSet').
- Make model element references consistent (e.g.
PropertyvsIPropertyvsstringvsPropertyInfo) - Add provider-specific extension methods for convention metadata interfaces.
- Rename and move
RelationalAnnotationsandRelationalAnnotationsBuilderto Core. - Remove unused methods on provider classes like
SqlServerPropertyBuilderAnnotations.ColumnName. - Rename the
Applymethods to be more descriptive and make the return types consistent, still allowing to stop the execution of the following conventions. - Pass
CoreConventionSetBuilderDependenciesto the constructor of all conventions. - Add convention type for configuring a type as owned and use it to remove ambiguous ownerships.
- Track the model elements as they are modified by conventions, so a call to a convention never returns an element that is no longer in the model.
- Add a way to delay the convention execution.
- Move logic from
ModelCustomizerto a convention. - Add
SqlServerValueGenerationStrategy.Nonevalue that can be used to override the model default. - Filter out the core annotations changes from conventions.
- Remove
PropertyMetadataChanged()calls and don't cache indexes while the model is mutable. - Expose conventions as
ListonConventionSet - Add methods to add/remove a convention to/from all appropriate convention lists.
- Add a
Conventionsproperty ofConventionSetBuildertype toModelConfigurationBuilderwith methods to add/remove a convention
Reacted by cwe1ss, Rob, webpony2016, Augusto Barreto, Luis Palacios, Ashley, Michel Bretschneider, MisinformedDNA, Amr, Muhammad Haseeb and 12 more
Reacted by Lukáš Novotný, Guilherme Britz Videira, Martin H. Andersen, awatson-scottlogic and AraHaan
Reacted by Guilherme Britz Videira, Martin H. Andersen, awatson-scottlogic and AraHaan
Activity
[-]Model Definition: Provide API for customizing conventions[/-][+]Model Definition: Provide API for custom conventions[/+][-]Model Definition: Provide API for custom conventions[/-][+]Model Definition: Custom conventions[/+]sthiakos commentedon Dec 26, 2015
This was useful for me in the following Scenarios:
** Creating an IStoreModelConvention for AssociationType to remove underscore from FK names,
** Creating an IStoreModelConvention for EntitySet to remove underscore from m-2-m join tables/dbsets (not applicable right now to EF Core).
** Auto-generation based on whether it's a Data-Dictionary/Lookup item (e.g. BlogType - static) vs an Entity (Blog - autogen). They are distinguished based on interface implementations.
** Give a common Class property (e.g. "StateId") but an explicit db column name (e.g. "BlogStateId"). Same goes for "Id" in code but "{Type}Id" in database.
Doing this once I was able to govern the entity definitions without requiring explicit entity declaration. I'm not advocating the same implementation, but do feel custom/override conventions are valuable.
Cheers,
Steve
rowanmiller commentedon Dec 28, 2015
Some of these types of things can be achieved by iterating over the model that is created by convention. This was not possible in EF6 because we collected a set of configuration during OnModelCreating and then used that plus conventions to build the model. But in EF Core we build an initial model from conventions and then pass that to OnModelCreating.
Of course, this means you need to be mindful of ordering. For example, if a type wasn't included in the model by convention, then you need to make sure you add it before you iterate over the model and assign table names.
Here is an example of appending an
sto the table name.sthiakos commentedon Dec 29, 2015
Thanks for the info Rowan,
I'll just need to explicitly load my entities in this method for my domain assembly:
This makes me think that perhaps an
OnEntityModelCreating(EntityTypeBuilder entityTypeBuilder)may help with conventions and keep things dynamic.Steve
tibitoth commentedon Jan 5, 2016
I see that this issue is not a priority issue, but will the custom conventions be implemented before RC2, or just before RTM? (I hope it will be at least in RTM)
ErikEJ commentedon Jan 5, 2016
According to the current roadmap it will be in 7.0.2 (?) https://github.com/aspnet/EntityFramework/wiki/Roadmap
120 remaining items
Improve convention API consistency test
Improve convention API consistency test
[-]Expose model building conventions to applications[/-][+]Allow applications to create model building conventions (aka public conventions)[/+]vupham1111 commentedon Nov 21, 2023
hello, I come from this #27400
does the ef core support the feature yet, if it does, I hope you can feed me some guidance, thank you so muchhhh
ajcvickers commentedon Nov 21, 2023
@vupham1111 See https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/whatsnew#model-building-conventions