I have got two tables in database
1) State (stateid,statename)
2) City(cityid, stateid, cityname)
I am using Entity framework for db manipulation
I want to insert data into City table with the reference to State Table using entity framework
For that i wrote the following code
MyModel mdl= new MyModel();
City ct=new City();
ct.cityname="Dallas";
ct.State=mdl.State.Where(u=>u.stateid==1);
mdl.AddToCity(ct);
mdl.SaveChanges();
There are data in "state" table.
But i am getting following error at "mdl.AddToCity(ct)"
"An entity object cannot be referenced by multiple instances of IEntityChangeTracker"