Hey everyone,
I'm working on a WPF system which hooks onto an old legacy database using the Entity Framework. We hook onto a backup of the live data when debugging and an empty database to run tests against. I'm receiving the following error only when trying to delete from a backup of the live data.
This code:
License license = ReadLicense(id);
entities.DeleteObject(license);
entities.SaveChanges();
produces this SQL:
exec sp_executesql N'delete [dbo].[Product]
where ((([Group_ID] = @0) and ([Parent_ID] = @1)) and ([Prod_ID] = @2))',N'@0 nvarchar(32),@1 nvarchar(32),@2 nvarchar(32)',@0=N'someIdValue1',@1=N'someIdValue2',@2=N'someIdValue3'
which in turn produces this error:
Msg 208, Level 16, State 1, Procedure TrackDeletedProduct, Line 4. Invalid object name 'DeletedRecords.dbo.Product_Deleted'.
If you change the generated SQL to a 'select' query it returns a row so, 'ReadLicense' is returning a valid entity. I can't really understand why this doesn't work, especially when it's only against live data. The 'License' entity is one of two inheriting from a base 'Product' entity.
Cheers.