Code: Select all
[Table(Name = "document_types")]
public class DocumentType
{
[Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
public int Id;
[Column]
public string Name;
}
... then, later in a method in another class...
var dcon = new VnDocsDataContext();
var dt = new DocumentType();
dt.Name = "This is a test";
dcon.DocumentTypes.InsertOnSubmit(dt);
dcon.SubmitChanges();
Code: Select all
An unhandled exception of type 'System.InvalidOperationException' occurred in Devart.Data.Linq.dll
Additional information: The entity ConsoleApplication3.DocumentType should be attached to the context to perform this operation.
Thanks -- Michael Watson