tags:

views:

88

answers:

1

hello,

I have table SublocationTbl that have SubLocationName and LocationId(this field is foreign key from table LocationTbl), and I have business entity data model I know that the foreign key dosen't appear in the business entity my problrm is: how can I set the value of locationId when I need to add new subLocation?

A: 

Something like this...?

using(var db = new myDbContext()) { var myNewSubLocation = new SubLocation(); myNewSubLocation.LocationID = 12345; //put ur value here

db.SubLocations.Add(myNewSubLocation); db.SubmitChanges(); }

alex
The problem is that locationId is foreign key and it dosen't appear in sublocations business entity so myNewSubLocation.LocationID not exist