In my model I have a detail table that will contain data for each day of the week, so it has this definition:
public class JournalDay
{
public int JournalID { get; set; }
public DayOfWeek Day { get; set; }
public TimeSpan From { get; set; }
public TimeSpan To { get; set; }
public virtual Journal Journal { get; set; }
}
In the EF Fluent API mapping class I define the composite key like this:
HasKey(jd => new { jd.JournalID, jd.Day });
But the table structure generated by Entity Framework only has the first column in the primary key:
CONSTRAINT [PK_dbo.Journals] PRIMARY KEY CLUSTERED
(
[JournalID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
Is this problem caused by the second column being a DayOfWeek enum ?? I've used enums before on composite keys and it never gave this problem