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\company.data.Sys.EFDAL\Data.csdl|~\Modules\company.data.Sys.EFDAL\Data.ssdl|~\Modules\company.data.Sys.EFDAL\Data.msl;provider=System.Data.SqlClient;provider connection string='server = 127.0.0.1,1433\sqlexpress;database = companydata;uid = sa;pwd = 123'";
var startup = new ContextStartup("sa");
using (var db = new company.data.Module1.EFDAL.dataEntities(startup, 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 : company.data.Module1.EFDAL\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