I’m attempting to add a mirgration before I run my project.
I get the following error when I attempt to add a mirgration
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.
Here is the class:
<Table("aspnet_Membership")>
Public Class UserMembership
Inherits User
Public Property ApplicationId As Guid
Public Property Comment As String
End Class
Its parent:
<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
Finally OnModelCreating:
modelBuilder.Entity(Of MembershipUser)().Map(Sub(m)
m.MapInheritedProperties()
m.ToTable("aspnet_Membership")
End Sub)
Anyone know what I’m doing wrong?
1 Answer