我正在尝试在运行项目之前添加一个镜像。
尝试添加镜像时出现以下错误
One or more validation errors were detected during model generation:
\tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'MembershipUser' has no key defined. Define the key for this EntityType.
\tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'MembershipUsers' is based on type 'MembershipUser' that has no keys defined.
这是班级:
<Table("aspnet_Membership")>
Public Class UserMembership
Inherits User
Public Property ApplicationId As Guid
Public Property Comment As String
End Class
其父母:
<ReadOnlyAttribute(True), Table("aspnet_Users")>
Public Class User
<Key, DatabaseGenerated(DatabaseGeneratedOption.Identity), DisplayName("User Id")>
Public Property UserId As Guid
<Required, StringLength(256)>
Public Property UserName As String
<Required, StringLength(256)>
Public Property LoweredUserName As String
<StringLength(16)>
Public Property MobileAlias As String
<Required>
Public Property IsAnonymous As Boolean
<Required>
Public Property LastActivityDate As DateTime
End Class
最后OnModelCreating:
modelBuilder.Entity(Of MembershipUser)().Map(Sub(m)
m.MapInheritedProperties()
m.ToTable("aspnet_Membership")
End Sub)
任何人都知道我做错了什么?
答案 0 :(得分:0)
有关MembershipUser的例外情况,但您的类名为UserMembership。这是一个错字吗?