This is my first attempt at Fluent NH. I save the connection string in Properties.Settings;
FnhDbString = Data Source=PC\SQLEXPRESS;Initial Catalog=FNHTest;Integrated Security=True
If I .FromAppSetting Fluent with .FromAppSetting , I get an exception:
ArgumentNullException Value cannot be null. Parameter name: Data Source
If I .FromConnectionStringWithKey Fluent with .FromConnectionStringWithKey , I get an exception:
NullReferenceException Object reference not set to an instance of an object.
Full method:
private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString(c => c .FromAppSetting(Properties.Settings.Default.FnhDbString)) .Cache(c => c .UseQueryCache()).ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Product>()) .BuildSessionFactory(); }
...
So what am I doing wrong here ??
source share