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 Documents\Visual Studio Codename Orcas\Projects\SqlServer\SqlContentProvider.cs:line 53
at SimpleWiki.DAL.Tests.DocumentTests.TestInsertingDocument() in E:\My Documents\Visual Studio Codename Orcas\Projects\Tests\DocumentTests.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 :).





Blogger comments