在一个实体中,我有以下声明:
Default Property Item(key As String) As String
因为实体框架不喜欢索引属性,所以我试图忽略它:
Public Class EntityMap
Inherits EntityTypeConfiguration(Of EntityMap)
Public Sub New()
' Me.Ignore(Function(x) x.Item()) --- Missing index parameter, compiler error
' Me.Ignore(Function(x) x.Item(String.Empty)) --- Gives runtime error
End Sub
End Class
我还尝试从模型构建器中删除所有发现约定,因此必须明确设置所有属性关系:
modelBuilder.Conventions.Remove(Of AssociationInverseDiscoveryConvention)()
modelBuilder.Conventions.Remove(Of ComplexTypeDiscoveryConvention)()
modelBuilder.Conventions.Remove(Of IdKeyDiscoveryConvention)()
modelBuilder.Conventions.Remove(Of NavigationPropertyNameForeignKeyDiscoveryConvention)()
modelBuilder.Conventions.Remove(Of PrimaryKeyNameForeignKeyDiscoveryConvention)()
modelBuilder.Conventions.Remove(Of TypeNameForeignKeyDiscoveryConvention)()
当执行获取实体的 linq 查询时,抛出异常“不支持索引属性”。
有人知道如何让实体框架忽略索引属性吗?该财产必须对其他实体公开。
提前致谢!