Im trying to call a stored procedure with entity framework that makes calls to a different server and I'm getting an error.
I searched on google and it says it is probably becuase Im calling a stored procedure on a DatabaseServer A that queries a table on DatabaseServer B and this causes for a circular reference. I wanted to know if there is a fix for this.
I tried googling the error and everywhere it is stated that I have to change the XACT_ABORT to off. But won't this make that only half my stored procedure goes through?
And I have a different code that calls the same stored procedure and there it works without any errors. I think the reason could be that I use dapper in my other project and here I use entity framwork.
The article of the error I found: https://support.microsoft.com/nl-nl/help/306212/how-to-troubleshoot-error-7391-that-occurs-when-you-use-a-linked-serve
context.Database.ExecuteSqlCommand("EXEC sp_StoredProcedure @param1,@param2",
new SqlParameter("param1", param1),
new SqlParameter("param2", param2));
The expect result is that the database updates go throught. This is the error im getting (note that the original error was in german and I had to google translate it):
The OLE DB provider 'SQLNCLI10' for the connection server 'DB008' could not start a nested transaction. A nested transaction was required because the XACT_ABORT option was set to OFF. The OLE DB provider 'SQLNCLI10' for the connection server 'DB008' has the message 'There is already a registration in the transaction.' hand back
SET XACT_ABORT ON;EXEC sp_StoredProcedure
.