LINQ Error ‘Can’t perform Create, Update or Delete operations’

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.

Type: System.InvalidOperationException
Source: System.Data.Linq
TargetSite: Void Attach(T)
HelpLink: null
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 :).

Technorati tags: ,

9 thoughts on “LINQ Error ‘Can’t perform Create, Update or Delete operations’”

  1. meeee tooo, thx a looot for tip. it’s crazy to spend half day with this nuisances, so thx again: for google and your tip

Leave a Reply

Your email address will not be published. Required fields are marked *