I have been playing around with LINQ to SQL and I was receiving an odd error message when inserting a entity into a table. The error was:
Message: Can’t perform Create, Update or Delete operations on ‘Table(dbo.DocumentRevisions)’ because it is read-only.
TargetSite: Void Attach(T)
Stack: at System.Data.Linq.Table`1.Attach(T item)
at SqlServer.SqlContentProvider.SaveDocument(Document document) in E:My DocumentsVisual Studio Codename OrcasProjectsSqlServerSqlContentProvider.cs:line 53
at SimpleWiki.DAL.Tests.DocumentTests.TestInsertingDocument() in E:My DocumentsVisual Studio Codename OrcasProjectsTestsDocumentTests.cs:line 28
I thought I had everything correctly, however I forgot to set a primary key in the table, hence Linq was unable to do anything with the object. So, lesson for the day Linq must have a Primary key for the table :).