流利配置
FluentConfiguration fc = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString)
);
映射配置
fc.ExposeConfiguration(cfg =>
cfg.SetProperty(NHibernate.Cfg.Environment.CurrentSessionContextClass, currentSessionContextClass))
.ExposeConfiguration(cfg =>
cfg.SetProperty(NHibernate.Cfg.Environment.CommandTimeout, "120")
);
fc.Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<BasicEntity>(autoMappingConf)
.UseOverridesFromAssemblyOf<AccountMappingOverride>()
.Conventions.Add(
DefaultCascade.SaveUpdate(),
new DefaultStringLengthConvention(),
new DefaultDecimalConvention()))
);
return fc;
内部异常是未使用数据库方法配置的数据库。 也是不完整的映射。
答案 0 :(得分:-1)
我只是改变位置
fc.Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<BasicEntity>
(autoMappingConf)
.UseOverridesFromAssemblyOf<AccountMappingOverride>()
.Conventions.Add(
DefaultCascade.SaveUpdate(),
new DefaultStringLengthConvention(),
new DefaultDecimalConvention()))
);
fc.ExposeConfiguration(cfg =>
cfg.SetProperty(NHibernate.Cfg.Environment.CurrentSessionContextClass,
currentSessionContextClass))
.ExposeConfiguration(cfg =>
cfg.SetProperty(NHibernate.Cfg.Environment.CommandTimeout, "120")
);
return fc;