Think on the following to gain a better understanding of the entity framework:
between your application and the database as a proxy.
unless you instruct it otherwise, will cache everything and use every piece of information from the cached values.
For 1.: Depending on your surroundings, whether your
is not disposed between choosing and changing the entities, you can call
you can save your data. When your
is disposed, it is possible to remove the entities from the context, alter the data, reattach the entities, and set the
Because I stopped utilizing the entity framework around six months ago, I can't guarantee a response. But I am aware that updating complicated relations is difficult.
For 2.: The instruction
instructs the EF not to keep track of any modifications made to the entities contained in this query. For instance, you might choose five TimeSheets from your database, modify the first entity's information, and delete the last one. The
if you call, it understands that the first entity has been altered and the last one has been erased.
update the first entity automatically, remove the final one, and leave the other ones alone. Now you attempt to update an entity independently while reassociating the first entity with the DbContext.
Now that two entities with the same key exist in the DbContext, your exception is the result.
is the object used by the entity framework to keep track of these entities' modifications.
For 4.: Check out this link. An excellent book about entity framework 6 is also available (Title: "Programming Entity Framework")