Created
August 15, 2018 01:33
-
-
Save rqx110/b14f22452b806ea0d039e78fa4eb8976 to your computer and use it in GitHub Desktop.
EF core 2.0 批量注册entityTypeConfiguration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string typeName = typeof(IEntityTypeConfiguration<>).Name; | |
var assembly = Assembly.GetExecutingAssembly(); | |
assembly.GetTypes() | |
.Where(w => w.GetTypeInfo().ImplementedInterfaces.Any(a => a.Name == typeName)) | |
.ToList() | |
.ForEach(item => | |
{ | |
dynamic instance = item.FullName; | |
builder.ApplyConfiguration(assembly.CreateInstance(instance)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also see https://stackoverflow.com/questions/47013752/bulk-register-ientitytypeconfiguration-entity-framework-core