1 protected override void OnModelCreating(ModelBuilder builder) 2 { 3 base.OnModelCreating(builder); 4 5 //var mi = builder.GetType().GetMethod("ApplyConfiguration"); 未升级前只有一个ApplyConfiguration方法 6 var mi = builder.GetType().GetMethods() 7 .Single( 8 e => e.Name == "ApplyConfiguration" 9 && e.ContainsGenericParameters10 && e.GetParameters().SingleOrDefault()?.ParameterType.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>));11 }