動態加載模型 的方法ui
base.OnModelCreating(builder); if (!isLoadModel) return; if (_ConfigurationInstance == null) { _ConfigurationInstance = new List<dynamic>(); var files= System.IO.Directory.GetFiles(AppContext.BaseDirectory, "*.Model.dll"); foreach (var dll in files) { var typesToRegister = Assembly.LoadFrom(dll).GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null); foreach (var type in typesToRegister) { dynamic configurationInstance = Activator.CreateInstance(type); _ConfigurationInstance.Add(configurationInstance); builder.ApplyConfiguration(configurationInstance); } } return; } foreach (var type in _ConfigurationInstance) { builder.ApplyConfiguration(type); }