It's my first attempt on Fluent NH. I store the connection string in Properties.Settings;
FnhDbString = Data Source=PC\SQLEXPRESS;Initial Catalog=FNHTest;Integrated Security=True
If I configure Fluent with .FromAppSetting I get exception:
ArgumentNullException
Value cannot be null. Parameter name: Data Source
If I configure Fluent with .FromConnectionStringWithKey I get exception:
NullReferenceException
Object reference not set to an instance of an object.
The 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..?