Reputation: 17177
I am trying to make a one-to-one relationship between the aspnet_Users
table and my own entity, Player
. To accomplish this, I added a Guid:
public class Player
{
public Guid ID;
// ...
However, this isn't automatically becoming the primary key, as I intended. How can I coerce this column to become the primary key?
Update:
After looking here, I added this to my Player
class:
using System.ComponentModel.DataAnnotations;
public class Player
{
[Key,Required]
public Guid ID;
// ...
But still, when I try to do a @foreach in my View, I get the error " EntityType 'Player' has no key defined"
Upvotes: 2
Views: 1602