Skip to content

Instantly share code, notes, and snippets.

@RyanABailey
Created November 25, 2015 07:16
Show Gist options
  • Select an option

  • Save RyanABailey/a4eaf9e4d8447299738d to your computer and use it in GitHub Desktop.

Select an option

Save RyanABailey/a4eaf9e4d8447299738d to your computer and use it in GitHub Desktop.
Entity First Composite Key
public class Raffle
{
public int RaffleId { get; set; }
public virtual List<Ticket> Tickets { get; set; }
}
public class Ticket
{
[Key, Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int TicketNumber { get; set; }
[Key, ForeignKey("Raffle"), Column(Order = 1)]
public int RaffleId { get; set; }
public virtual Raffle Raffle { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment