EntityFramework 6 - Transient.collection Exception



i具有以下数据库 - 第一模型:

Imports System
Imports System.Collections.Generic
Partial Public Class User
    Public Property ID As Integer
    Public Property Username As String
    Public Property Password As String
    Public Property IsDisabled As Boolean
    Public Property IsSuper As Boolean
    Public Property MustChangePassword As Boolean
    Public Property Notes As String
    Public Overridable Property UserPermissions As ICollection(Of UserPermission) = New HashSet(Of UserPermission)
End Class

和DB上下文

Partial Public Class Entities
Inherits DbContext
Public Sub New()
    MyBase.New("name=Entities")
End Sub
Protected Overrides Sub OnModelCreating(modelBuilder As DbModelBuilder)
    Throw New UnintentionalCodeFirstException()
End Sub
.
.
.
Public Overridable Property Users() As DbSet(Of User)
.
.
.
End Class

每当我运行以下查询时:

dim ent = New Entities()
result = (From u In ent.Users
          Where u.ID = ID
          Select u).SingleOrDefault()

我有以下错误:

'用户'不是'transient.collection [conso_model.entity(nullable = true,defaultValue =)]]的成员。要提取集合元素的属性,请使用子查询在集合上进行迭代。靠近逃脱的标识符,第1列第12列。

有任何线索?

找到了问题!还有另一个名为"实体"的EF类"实体"实体"(类似于数据库上下文类)!

愚蠢的VB编译器如何没有发出任何警告!

相关内容

  • 没有找到相关文章

最新更新