I started using EF 4.1 code first.
I have a entity table like this:
public AMapping()
{
Property(x => x.Counter).IsRequired();
HasKey(x => x.AID);
HasKey(x => x.BID);
HasRequired<A>(x => x.A)
.WithMany(y => y.CList)
.HasForeignKey(f => f.AID);
ToTable("A");
}
Table A column look something like this:
AID(PK, FK, int, not null)
Counter(int, not null)
BID(PK, FK, int, not null)
While writing save integration test it is giving following error:
Cannot insert the value NULL into column ‘BID’, table ‘Sprint3.dbo.A’;
column does not allow nulls. INSERT fails.
But I can see that I’m passing an integer value.
Is there any constraint about composite primary keys in EF 4.1 code first?
Never used it, just saw it in the docs yesterday 🙂