We have some performance issues with our EF4 MVC solution. We were able to track it before ArithAbort was installed in front of all database connections, and now we are trying to make it remain 'ON'.
We looked: How do you control the "SET" statements issued by Linq to SQL
But it seems that EF4 drops the connection before each request, so this will not work.
So far, we have tried to βset ArithAbort onβ before this request, with no luck. We also tried to go a long way and create a new connection, where we established it, but still no luck.
So, does anyone know how we can install it before making any linq queries to the database?
Changing database settings is not an option.
Edit: At the suggestion of Andiihs, I tried the shell solution and added the EFCachingCommand class to the following lines of code
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 a prefix with the correct set statement.
I also had to add:
DbFunctionCommandTree functionTree = commandTree as DbFunctionCommandTree; if (functionTree != null) { this.IsModification = true; return; }
To the GetAffectedEntitySets function in EFCachingCommandDefinition to make it work correctly with stored procedure calls.
source share