Tuesday, 15 June 2010

c# - Entity Framework: Navigation Properties as Primary Keys -



c# - Entity Framework: Navigation Properties as Primary Keys -

i'm using ef 6 mvc 5. have class defined follows:

public class conedsignup { [key, column(order = 0)] public virtual applicationuser attendee { get; set; } [key, column(order = 1)] public virtual conedsession conedsession { get; set; } [required] public datetime signuptime { get; set; } [required] public bool attended { get; set; } }

this link table many-to-many relationship have additional properties relationship. when seek create migration this, gives me error "models.conedsignup: : entitytype 'conedsignup' has no key defined. define key entitytype."

i defined keys it, doesn't it. how can utilize these navigation properties primary keys?

you should read article on msdn :-

http://msdn.microsoft.com/en-gb/data/jj679962.aspx

it explains conventions entity framework adheres too. explains how create own custom conventions.

you need setup classes in specific way ef recognises trying achieve.

c# asp.net-mvc entity-framework

No comments:

Post a Comment