Whats the Perfered Method to handle Errors in a SQL Stored Procedure when Using Entity Framework.
I have a chunk of code that uses a database context and EF to call a stored procedure. If everything is perfect, the stored procedure returns a list of keys to tell me which records were modified. If something goes wrong in the stored procedure, the transaction rolls back and I believe the response type is a string and causes this error:
The data reader has more than one field. Multiple fields are not valid for EDM primitive or enumeration types.
After doing so digging I noticed that the SQL developer had put "PRINT: ERROR MESSAGE HERE" statement to pass back a message, However the current call does not allow for this,
Here is how the call is currently being made:
var partIdsCreated = context.Database.SqlQuery<int>("EXEC My_SP @FilePath, @FileName", args).ToList();
The Current Code is expecting a list of Int and if a string is Returned it Errors out with the Error Message listed above, So what is the best way to handle errors coming back from a Stored Procedure in a Transaction Using Entity Framework 6?