はType.ContainsGenericParametersは私が動的にインスタンスを作成するリフレクションを使用しています
trueであるためのインスタンスを作成できません。
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);
}
と私の例外は以下の通りです: - は "Type.ContainsGenericParametersが真であるのでCGenericConfigurationClass`1 [T]のインスタンスを作成できません。"
画像が役に立たない。削除してコードを表示してください。また、EFにはアセンブリ内の 'EntityTypeConfiguration'クラスを発見する組み込み関数があります。 –
は、正確なコードを取得するためのライブメールを提供します。 –
私は、efのEntityTypeConfigurationクラスを使用してマルチレベルの継承を使用したいと考えています。アイデアや解決策を教えてください。 –