无法创建,因为Type.ContainsGenericParameters是真的
我创建一个实例使用动态反映一个实例。
var typesTR = Assembly.GetAssembly(typeof(BGenericConfigurationClass<>)).GetTypes()
.Where(type =>
!string.IsNullOrEmpty(type.Namespace) &&
(type.Namespace == "EntitiesConfiguration"))
.Where(type => type.BaseType != null
&& type.BaseType.IsGenericType
&&
(type.BaseType.GetGenericTypeDefinition() == typeof(BGenericConfigurationClass<>) ||
type.BaseType.GetGenericTypeDefinition() == typeof(CGenericConfigurationClass<>)));
foreach (var type in typesTR)
{
dynamic configurationInstance = Activator.CreateInstance(type);
modelBuilder.Configurations.Add(configurationInstance);
}
和我的异常以下内容: - “无法创建CGenericConfigurationClass`1 [T]的实例,因为Type.ContainsGenericParameters是真实的。”
该图像根本没有帮助。请删除它并显示代码。另外,请注意,EF有一个内置函数来发现程序集中的“EntityTypeConfiguration”类。 –
提供您的实时电子邮件以获取确切的代码。 –
我想使用ef的EntityTypeConfiguration类的多级继承。给我任何想法或任何解决方案。 –