What does LINQ-to-SQL Table<T>.Attach do?
What exactly does the LINQ-to-SQL method Table<T>.Attach() and Table<T>.AttachAll() and what is an example/situation for their proper usage? Also, please check out this related question: How to detach a LINQ-to-SQL data object from the DataContext's tracking mechanism? It is really useful in multi-tier applications that serialize/deserialize data to other layers. Short version: Attach() tells DataContext the entity is not new (for insert ) but an updated entity that is meant to be updated in the DB. Long version: You have a DataContext where your entities exist. New entities get inserted,