What is the best way to set SQL Server Context_Info using CSLA and EF5?

What is the best way to set SQL Server Context_Info using CSLA and EF5?

Old forum URL: forums.lhotka.net/forums/t/12020.aspx


correodemarques posted on Wednesday, June 12, 2013

Hi all,

We need to log changes to the data using triggers in SQL Server 2012. The problem is that we need the id of the user that is currently accessing the database. We can set and later retrieve that id using SET CONTEXT_INFO (http://msdn.microsoft.com/en-us/library/ms187768.aspx) but that should be done when the connection is opened and with Csla managing connections, I don't know where to start.

Is there a way of doing this without modifying Csla code? I'm afraid that I'm not very familiar with the way the Csla DbContextManager works.

I'm using Csla 4.5.3 and Entity Framework 5.

Thanks in advance for your help.

JonnyBee replied on Wednesday, June 12, 2013

Hi,

I think the simplest is to make a copy of the DbContextManager in your own assembly and make the necessary changes when the connection is initialized. 

Copyright (c) Marimer LLC