This is my database structure I have four tables. Table LocalArea and Lanungaue have master data and which refered by the tables Address and AddressTranslated
Now I want to add rows in Address and AddressTranslated table I used following code store Address table row
Address.localarea = new localarea() { LocalAreaID = 1 };
using (var context = new en_Entities())
{
context.Address.Attach(Address);
context.ObjectStateManager.ChangeObjectState(Address.LocalArea, EntityState.Unchanged);
context.ObjectStateManager.ChangeObjectState(Address, EntityState.Added);
context.SaveChanges();
}
The code working fine and adds row in Address table.
How do i add row in AddressTranslated ?? what changes/line of code do i need to add data in AddressTranslate table.
My AddressTranslated table was not having any primary key column thats why couldnt add row to childtable.
After adding a primary key column all records got saved to DB.