<p>Code below does not run correctly and throws <code>InvalidOperationExcepiton</code>.</p>

<pre><code>public void Foo()
{
 DataContext context = new DataContext();
 LinqEntity item = new LinqEntity(){ Id = 1, Name = "John", Surname = "Doe"} ;
 context.LinqEntities.Attach(item, true);
}
</code></pre>

I'm not sure what you mean by disconnected from the database.
It appears that you are trying to insert a new row into the LinqEntities table -- is that correct?
If that is the case you'll want to do
```
```
context.LinqEntities.InsertOnSubmit(item);
context.Submit();
```
```