EntityType 'MyProfile' has no key defined. Define the key for this EntityType

后端 未结 2 1369
甜味超标
甜味超标 2021-02-18 23:32

I am not sure why I am getting this error message. I have a primary key defined in my sql database for it. Here is my code:

[HttpPost]
    public ActionResult          


        
相关标签:
2条回答
  • 2021-02-18 23:50

    I ran into this issue also and wanted to add that in Entity Framework version 6 this error occurs because the DbgGeography type has been moved from the assembly system.data.entity and into the entityframework.dll

    to resolve this in EF 6+ remove the reference to the entity dll and change the using statement to using System.Data.Entity.Spatial

    see this http://entityframework.codeplex.com/workitem/1535

    0 讨论(0)
  • 2021-02-18 23:54

    Which field is your key? Whichever it is - ProfileId or UserId - either change the name to MyProfileId or Id or else put a [Key] attribute on it.

    0 讨论(0)
提交回复
热议问题