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 :).
yeah, i encounter the same problem
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
Thanks!
Thanks
Very Very Thanks!
Thanks for the tip off buddy: You saved the day!
My hero… 🙂 Thanx
Thanks everyone, pleased it has been useful for you all.
thanks.