entity object cannot be referenced by multiple instances of IEntityChangeTracker. while adding related objects to entity in Entity Framework 4.1

Because these two lines … … don’t take a parameter in the constructor, I guess that you create a context within the classes. When you load the city1… …you attach the city1 to the context in CityService. Later you add a city1 as a reference to the new Employee e1 and add e1 including this reference to city1 to the context in EmployeeService. As a result you have city1 attached to … Read more

Why does var evaluate to System.Object in “foreach (var row in table.Rows)”?

That’s because the DataRowCollection class only implements the non-generic version of IEnumerable. So the compiler doesn’t know what the type of the variable is. By explicitly putting the type in there, you basically tell the compiler to generate an explicit cast from object to DataRow. This is a problem you’ll find with many of the collections and classes added back in … Read more