We are having some performance issues with our EF4 MVC solution. We've been able to track it down to ArithAbort getting set to off before all connections to the database, and now we are trying to force it to stay as 'ON'.
We've looked at: How do you control the "SET" statements emitted by Linq to SQL
But it seems like EF4 is resetting the connection before each query, so that won't work.
So far we've tried "set ArithAbort on" before a given query, with no luck. We've also tried going the long way and making a new connection where we set it, but still no luck.
So, anyone have a clue as to how we can get it to set it before making any linq queries against the database?
Changing database settings isn't an option.
Edit: Per Andiihs suggestion I tried out the wrapper solution and added in the following lines of code to the EFCachingCommand class
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
{
if (this.WrappedCommand.CommandType == System.Data.CommandType.Text)
{
this.WrappedCommand.CommandText = "set arithabort on; " + this.WrappedCommand.CommandText;
}
This essentially ensures that any Linq-sql calls get prefixed with the right set statement.
I also had to add:
DbFunctionCommandTree functionTree = commandTree as DbFunctionCommandTree;
if (functionTree != null)
{
this.IsModification = true;
return;
}
To the GetAffectedEntitySets function in the EFCachingCommandDefinition, in order to get it to work properly with stored procedure calls.