Reputation: 3609
I am trying to use a complex type as a key on an entity, however I can't get it to work and not sure if this is just a limitation of the version I am using. I am sure that I have seen it done somewhere.
Can a complex type be used as an key in Entity Framework 5.0??
If so how can this be done??
public class Identity : IIdentity
{
public string Id { get; protected set; }
public Identity()
{
Id = Guid.NewGuid().ToString();
}
public Identity(string id)
{
}
}
public class ReviewId : Identity
{
public ReviewId(string id): base(id)
{
}
public ReviewId()
{
}
}
public class Review
{
public ReviewId ReviewId { get; set; }
}
Entity Framework complains about using ReviewId as a key.
Upvotes: 0
Views: 75