I just stumbled upon this question as I was looking for the answer. I found that it is not (yet?) Implemented in EF Core, but can be implemented quite easily.
You can create one of them:
using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Microsoft.EntityFrameworkCore { public abstract class EntityTypeConfiguration<TEntity> where TEntity : class { public abstract void Map(EntityTypeBuilder<TEntity> modelBuilder); } public static class ModelBuilderExtensions { public static void AddConfiguration<TEntity>(this ModelBuilder modelBuilder, EntityTypeConfiguration<TEntity> configuration) where TEntity : class { configuration.Map(modelBuilder.Entity<TEntity>()); } } }
And then you can create a configuration for the entity itself: -
using Microsoft.EntityFrameworkCore; using Project.Domain.Models; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Project.Persistance.EntityConfigurations { public class MyEntityConfiguration : EntityTypeConfiguration<MyEntity> { public override void Map(EntityTypeBuilder<MyEntity> modelBuilder) { modelBuilder .Property();
Then you can download all your configurations somewhere (maybe the best way and the best place for this ... but this is what I did): -
using Microsoft.EntityFrameworkCore; using Project.Domain.Models; using Project.Persistance.EntityConfigurations; namespace Project.Persistance { public class MyDbContext : DbContext {
source share