Suppose I have three tables: Tab1(Cola, ,,,,) Tab2(Colb,....), tab3(cola, colb,...)
Cola is primiary key for tab1, colb is primary key for tab2. Tab3 is a relationship of tab1 and tab2, so cola, colb is foreign keys for tab3.
For tab1 and tabl2, becuase thery are entity, so I can use datacontext db to add a new instance like:
db.Tab1s.InsertOnSubmit( tab1 obj);
db.Save();
db.Tab2s.InsertOnSubmit(tab2 obj);
db.Save();
But When I try to insert data to tab3 in simiar way:
db.Tab3s.InsertOnSubmit(tab3 obj);
I got exception eroro said that tabl3 has no primiary key. tab3 only have a index on cola, colb:
- ex {"Can't perform Create, Update or Delete operations on 'Table(Tab3)' because it has no primary key."} System.Exception {System.InvalidOperationException}
How to resolve this issue?