I have a 1-to-0..1 relationship defined in an Entity Framework code first model like this:
public class Album
{
public int AlbumId { get; set; }
public int StampId { get; set; }
public Stamp Stamp { get; set; }
// other properties
}
public class Stamp
{
public int StampId { get; set; }
public int AlbumId { get; set; }
[Required]
public Album Album { get; set; }
// other properties
}
So.. an album has 0..1 stamps, a stamp always has exactly one album. The configuration I have here works nicely. However when I look at what columns are generated in the data base, I'm a bit unhappy: The foreign key is created in the Album
table.. which makes it a hard/slow to bulk-insert new Stamps, as you always need to alter the Album
table and update the StampId
Foreign Keys there. (That means I need change tracking to change those fields)
How can I tell Entity Framework to create the foreign key in the Stamp
table?
I'm also not sure what role the declaration of the navigation properties play in this context.. does it matter whether you have those properties defined in both directions?