ModelBuilder.ApplyConfigurationsFromAssembly 方法

定义

从提供程序集中定义的所有 IEntityTypeConfiguration<TEntity> 实例应用配置。

public virtual Microsoft.EntityFrameworkCore.ModelBuilder ApplyConfigurationsFromAssembly (System.Reflection.Assembly assembly, Func<Type,bool> predicate = default);
public virtual Microsoft.EntityFrameworkCore.ModelBuilder ApplyConfigurationsFromAssembly (System.Reflection.Assembly assembly, Func<Type,bool>? predicate = default);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This API isn't safe for trimming, since it searches for types in an arbitrary assembly.")]
public virtual Microsoft.EntityFrameworkCore.ModelBuilder ApplyConfigurationsFromAssembly (System.Reflection.Assembly assembly, Func<Type,bool>? predicate = default);
abstract member ApplyConfigurationsFromAssembly : System.Reflection.Assembly * Func<Type, bool> -> Microsoft.EntityFrameworkCore.ModelBuilder
override this.ApplyConfigurationsFromAssembly : System.Reflection.Assembly * Func<Type, bool> -> Microsoft.EntityFrameworkCore.ModelBuilder
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This API isn't safe for trimming, since it searches for types in an arbitrary assembly.")>]
abstract member ApplyConfigurationsFromAssembly : System.Reflection.Assembly * Func<Type, bool> -> Microsoft.EntityFrameworkCore.ModelBuilder
override this.ApplyConfigurationsFromAssembly : System.Reflection.Assembly * Func<Type, bool> -> Microsoft.EntityFrameworkCore.ModelBuilder
Public Overridable Function ApplyConfigurationsFromAssembly (assembly As Assembly, Optional predicate As Func(Of Type, Boolean) = Nothing) As ModelBuilder

参数

assembly
Assembly

要扫描的程序集。

predicate
Func<Type,Boolean>

可选谓词,用于筛选程序集中的类型。

返回

相同的 ModelBuilder 实例,以便可以链接其他配置调用。

属性

注解

有关详细信息和示例,请参阅 为实体类型和关系建模

适用于