Это моя первая попытка на Fluent NH. Я храню строку подключения в Properties.Settings;
FnhDbString = Data Source=PC\SQLEXPRESS;Initial Catalog=FNHTest;Integrated Security=True
Если я настраиваю Fluent с .FromAppSetting
, я получаю исключение:
ArgumentNullException
Value cannot be null. Parameter name: Data Source
Если я настраиваю Fluent с .FromConnectionStringWithKey
, я получаю исключение:
NullReferenceException
Object reference not set to an instance of an object.
Полный метод:
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();
}
...
Так что же я здесь не так делаю ..?