问题
In an entity I have following declaration:
Default Property Item(key As String) As String
Because Entity Framework doesn't like indexed properties I've tried to ignore it:
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
I've also tried to remove all discovery conventions from modelBuilder so all property relations explicitely must be set:
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)()
When the linq query to fetch entities is executed the exception "Indexed properties are not supported" is thrown.
Anyone having any idea how to let Entity Framework ignore the indexed property? The property must be public to other entities.
Thanks in advance!
来源:https://stackoverflow.com/questions/6199442/let-entity-framework-code-first-ignore-an-indexed-property