I need to execute a stored procedure with Entity Framework.
Normally I call it like this:
However, this particular stored procedure includes accessing a linked server.
Since EF wraps
ExecuteSqlCommand in a transaction, it is failing, as a linked server is not supported in a transaction (as far as I can tell).
Is there a way to execute this stored procedure with Entity Framework without it being in a transaction?
TransactionalBehavior.DoNotEnsureTransaction as the first parameter to the
this.Context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "EXEC edi_UploadTransmission");
My recommendation would be to simply not use EF for this part of your code. You can freely combine EF with straight ADO.NET code or with other ORMs such as Dapper or Chain.