This project is read-only.


error using audit tracking -conn string not set.


I'm using the modules feature and enabled ''Allow audit tracking'' to audit changes on records.

I am using this code to get the audit records of a model instanse
   const string cnnstr = @"metadata=~\Modules\\Data.csdl|~\Modules\\Data.ssdl|~\Modules\\Data.msl;provider=System.Data.SqlClient;provider connection string='server =,1433\sqlexpress;database = companydata;uid = sa;pwd = 123'";
            var startup = new ContextStartup("sa");

            using (var db = new, cnnstr))
                var record = db.ChildItem.FirstOrDefault();

                if (record != null)
                    var auditrecs=  record.GetAuditRecords().ToList();
As you can see i am passing in the connection string directly to the db context.

When it gets to line : record.GetAuditRecords() an error is caused :''Null reference object'' and i cannot get the audit records.
I've pinpointed the problem at this line of code :
    var s = System.Configuration.ConfigurationManager.ConnectionStrings["dataEntities"].ConnectionString;
inside file :\dataEntities.Generated.cs.

It seems that it is assuming connection string will be in the config file (which it isnot because i am passing it by code) and since it doesnt find it it blows.

Could'nt find a way to get around it. I think that the audit record classes need to be aware of the db context that is calling them in order to use the same connection string.

Hope this can be fixed as this is one of the best features of nhydrate , for me.

see attached model file for example


file attachments

Closed Aug 8, 2013 at 8:46 PM by codetools
This was an issue with a old version. This has been tested in the latest version and is no longer an issue. Please download latest version.


codetools wrote May 1, 2013 at 7:28 PM

This will be addressed in the next version in that an instance will read the connection string of its parent context. Also the context will have ConnectionString property. And finally the static audit methods will have an overload to pass in a connection string.

giannik wrote May 1, 2013 at 8:21 PM

sounds great.
Thanks Chris.

wrote Aug 8, 2013 at 8:46 PM