How do I create a new sql server session in entity framework?

Hoboly
Hoboly used Ask the Experts™
on
How do I create a new sql server session in entity framework?

Thanks~
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
All I need is to change @@SSPI

Author

Commented:
sorry, All I need is to change @@SPID, not @@SSPI
Perhaps what you are requesting is not what you really need? What are you trying to accomplish? Multi-threading?
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I am using asp.net mvc + entity framework to make a website.
different users(not domain/windows user) can login.
For each table, there is a trigger. It records every changes.
The trigger uses the @@SPID to distinguish different users.

However, I found that the entity framework re-use the same connection and same session.
so @@SPID cannnot distinguish between users.

Top Expert 2012
Commented:
You are going to have to resort to:
A.  Use the kludge of changing the connection string so that you can use the HOST() function or
B.  Pass in the user name to each Stored Procedure.
Ted BouskillSenior Software Developer
Top Expert 2009
Commented:
Pass the user name in each stored procedure as @acperkins suggested.

Playing around with the connection string will prevent the connection pool from being used properly and slow your application considerably.

Author

Commented:
I am using entity framework to update the table directly.
do you mean that I need to pass the username by stored procedure updating the table?
Top Expert 2012
Commented:
Yes, that is what we are recommending you do.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial