Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to annotate two relations into another table
Message
De
15/06/2015 18:03:23
 
 
À
15/06/2015 11:57:27
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01621011
Message ID:
01621018
Vues:
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; }
>}
>

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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform