efcore
efcore copied to clipboard
Add Generic version of EntityTypeConfiguration Attribute
Add generic arguments support for EntityTypeConfiguration attribute
From
[EntityTypeConfiguration(typeof(ModelConfiguration))]
public class Model
{.....}
To
[EntityTypeConfiguration<ModelConfiguration>()]
public class Model
{.....}
Should we extend EntityTypeConfigurationEntityTypeAttributeConvention
with the new EntityTypeConfigurationAttribute<T>
or create a new one?
@Marusyk Probably extend, unless that doesn't work very well.
Is this one up for grabs?
@joelmandell Yes.
Useful feature for DDD when parent class is generic Entity or AggregateEntity
In order to add generic constraint as the below should we move IEntityTypeConfiguration from EFCore to the abstraction project , since the type EntityTypeConfigurationAttribute exists in EFCore.Abstractions project , or we move the generic implementation to the EFCore project fix
where TEntity : IEntityTypeConfiguration
@OsamaAbuSitta We will discuss. The problem is that IEntityTypeConfiguration
has other dependencies that we cannot move. We may not be able to add a constraint to the generic argument.
@ajcvickers , In that case, should I proceed with submitting the pull request? for this changes commit
@OsamaAbuSitta We discussed this and we think its reasonable to put the generic version in the EntityFramework.Core
assembly. (It was pointed out that in other to use this, there would already need to be a reference from the assembly containing the entity types to the assembly containing the configuration, which in turn must reference the main EF assembly, so we don't actually gain anything here by putting it in Abstractions.)
Also, leave the existing non-generic class where it is.