Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to annotate two relations into another table
Message
From
15/06/2015 11:57:27
 
 
To
All
General information
Forum:
ASP.NET
Category:
Entity Framework
Title:
How to annotate two relations into another table
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:
01621011
Views:
54
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; }
}
Next
Reply
Map
View

Click here to load this message in the networking platform