Hello everyone,
I am working on a project that uses EF to do crud operations against the database I'm working with. I created several stored procedures to do the insert, update and delete operations because I am doing two things, I'm adding a record to an audit table and i'm performing the crud operation itself.
My problem is that during execution of the code I get a run time exception that I haven't found an answer for online. The Error occurs inside the Context class generated by EF.
<pre>return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<DeleteEDeliveryScheduledEvent_Result>("DeleteEDeliveryScheduledEvent", eventIdParameter, modifiedByParameter);
The Error is as follows:
Quote:
System.Data.Entity.Core.EntityCommandExecutionException
HResult=0x8013193C
Message=The data reader is incompatible with the specified 'AgentPortalModel.DeleteEDeliveryScheduledEvent_Result'. A member of the type, 'ErrorNumber', does not have a corresponding column in the data reader with the same name.
my standard delete stored procedure has the following structure:
CREATE PROCEDURE [dbo].[DeleteEDeliveryScheduledEvent]
@EventId INT = NULL,
@ModifiedBy int
AS
SET NOCOUNT ON;
IF @EventId IS NOT NULL
BEGIN TRANSACTION
BEGIN TRY
INSERT INTO EDeliveryAudit
(TableName,
ActionId,
RowXml,
ModifiedBy,
ModifiedDate)
VALUES ('EDeliveryScheduledEvents',
3,
(SELECT EventId,
EventDateTime
FROM EDeliveryScheduledEvents
WHERE EventId = @EventId
FOR XML RAW ('ScheduledEvent'), ROOT ('ScheduledEvents'), ELEMENTS ),
@ModifiedBy,
GETDATE())
DELETE FROM EDeliveryScheduledEvents
WHERE EventId = @EventId
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION
END CATCH
IF @@TRANCOUNT > 0
COMMIT TRANSACTION
What I have tried:
I've tried using out parameters.
I've tried using the ObjectContext to invoke the EF function directly