Session: How to Clear a Session

To clear session state, to stop tracking entities and remove all pending commands, etc. the Clear method is used from the Advanced session operations.

Syntax

void Clear();

Example

session.Store(new Employee
{
    FirstName = "John",
    LastName = "Doe"
});

session.Advanced.Clear();

session.SaveChanges(); // nothing will happen