Search code examples
c#sql-servermulti-user

SQL Server database is set Multi-User Mode and return error Single-User Mode


My database always are set in multi-user mode, my connection string has option mars = true, but after check the database error logs I can frequently see this error message

The server will drop the connection, because the client driver has sent multiple requests while the session is in single-user mode. This error occurs when a client sends a request to reset the connection while there are batches still running in the session, or when the client sends a request while the session is resetting a connection. Please contact the client driver vendor.

I don't know what I forget to change for activate multi-user mode.... I try activate multi-user mode because is a the best recommendation after read some post by other users

Why my session is in single user mode?

Some friends recommend to use mars = false and avoid multi-user mode

Is that a good idea ?

The connection string

<add name="BaseEntities"

connectionString="metadata=res://*/BaseModel.csdl|res://*/WMSModel.ssdl|res://*/BaseModel.msl;&#xD;&#xA; 
     provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MyServer;&#xD;&#xA; Initial Catalog=MyDatabase;Persist Security Info=True;User ID=myuser;Password=mypassword;&#xD;&#xA;         
     MultipleActiveResultSets=True;Application Name=EntityFramework&quot;"
     providerName="System.Data.EntityClient" />

After check db user-mode i get

SELECT user_access_desc 
FROM sys.databases 
WHERE name = 'MyDatabase'

return MULTI_USER

I use C#, Entity Framework 4.X, SQL Server 2008

Thanks for your attention


Solution

  • after some days the error logs disapear. the solution was removed MARS option

    i know 2 ways for set this options: in SQL Manage Admin select database -> options -> set Mars to false

    in connection string add MultiActiveResultSet=false

    Thanks guys for your help my problem was solved