Radgrid not updating database
If you use timestamps, tje object you want to delete needs the PK set and the Row Version Property in order to update it successfully!I was setting the row Version (timestamp) property, after I have attached the object to the respective Db Set, that's why it didn't work. I ran into this and it was caused by the entity's ID (key) field not being set.Thus when the context went to save the data, it could not find an ID = 0.Be sure to place a break point in your update statement and verify that the entity's ID has been set.Luckily in may case the trigger functionality was incorrect, but I guess it could be a valid operation that should somehow be handled in code. To expand on the comment by @jahu, I had to get an actual id of the newly inserted item to be returned from my trigger and the column name has to match the trigger table's identity column (in my case, actually a view so it didn't have an identity of its own but I had tricked the edmx into believing it did).My trigger was doing an insert into a separate table, so I just added this last line to my trigger: In my case I was doing a delete operation on entities in a child collection but there was a trigger on delete for one of the child entities that caused another of the child entities to be deleted.At the time you are saving the object to db, you need the previous value of the Row Version submit to the db along with the object for the concurrency check.You make silly mistakes when you need things faster!
For me the issue was I didn't have the sql table setup correctly.
One way to debug this problem in an Sql Server environment is to use the Sql Profiler included with your copy of Sql Server, or if using the Express version get a copy of Express Profiler for free off from Code Plex by the following the link below: Express Profiler By using Sql Profiler you can get access to whatever is being sent by EF to the DB.
In my case this amounted to: exec sp_executesql N'UPDATE [dbo].[Category] SET [Parent ID] = @0,  = NULL,  = @1, [Member ID] = @2, [Added On] = @3 WHERE ([Category ID] = @4) ', N'@0 uniqueidentifier,@1 nvarchar(50),@2 uniqueidentifier,@3 datetime2(7),@4 uniqueidentifier', @0='E060F2CA-433A-46A7-86BD-80CD165F5023',@1=N'I-Like-Noodles-Do-You',@2='EEDF2C83-2123-4B1C-BF8D-BE2D2FA26D09', @3='2014-01-29 .0435565',@4='3410FD1E-1C76-4D71-B08E-73849838F778' go I copy pasted this into a query window in Sql Server and executed it.
Sure enough, although it ran, 0 records were affected by this query hence the error being returned by EF.
In my case the problem was caused by the Category ID.