Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to annotate two relations into another table
Message
From
16/06/2015 19:24:19
 
 
To
15/06/2015 18:03:23
General information
Forum:
ASP.NET
Category:
Entity Framework
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01621011
Message ID:
01621049
Views:
40
>>In a punch clock application, a given Day has two foreign keys into the Punches table: PunchId_In and PunchId_Out. How can you annotate this relationship so Entity Framework creates it as intended? Note: One or both of these foreign keys may be undefined (null).
>>
>>
>>public class Day
>>{
>>    public int DayID { get; set; }
>>    public int? PunchId_In { get; set; }
>>    public int? PunchId_Out { get; set; }
>>    public virtual Punch PunchIn { get; set; }
>>    public virtual Punch PunchOut { get; set; }
>>}
>>
>>public class Punch
>>{
>>    public int PunchId { get; set; }
>>    public DateTime PunchDT { get; set; }
>>}
>>
>
>Add the ForeignKey attribute on your Punch properties to point to the corresponding PunchId. See https://msdn.microsoft.com/en-us/data/jj591583.aspx#Relationships.

Thanks Rob
Previous
Reply
Map
View

Click here to load this message in the networking platform