amirrajan/Oak — Issue #5: Composite Primary Keys in Seed
Author: amirrajan
Created: 2012-02-23 15:12:50+00:00
State: open

Email from Sasha Cikusa:

Just trying it out and noticed the in the following code (made up test table), SalesPersonRegion is not created with a composite PK

string tbl = seed.CreateTable("Region", new dynamic[]
{
new { RegionId = "int", Identity = true, PrimaryKey = true },
new { Code = "varchar(2)"},
new { Name = "varchar(12)"}
});
tbl.ExecuteNonQuery(cp);

tbl = seed.CreateTable("SalesPerson", new dynamic[]
{
new { SalesPersonId = "int", Identity = true, PrimaryKey = true },
new { RegionId = "int", ForeignKey = "Region(RegionId)" },
new { Name = "varchar(12)"}
});
tbl.ExecuteNonQuery(cp);

tbl = seed.CreateTable("SalesPersonRegion", new dynamic[]
{
new { SalesPersonId = "int", PrimaryKey = true, ForeignKey = "SalesPerson(SalesPersonId)" },
new { RegionId = "int", PrimaryKey = true, ForeignKey = "Region(RegionId)" }
});
tbl.ExecuteNonQuery(cp);

It's not uncommon so I wanted to let you know.