如果使用Manage Nuget Packages安装FluentNhibernate时,提示安装失败,“Install failed. Rolling back...”(安装失败,回滚)等信息时,只需要执行如下命令即可:
regsvr32 "C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VsLangproj.olb"
一、Access数据库配置
NHibernate本身不支持Access数据库,一开始看网上各种文档,捣敲浪费了N分钟。还是祭起Nuget神器引用NHibernate.JetDrive。代码如下,搞定收工。。。
private string FilePath { get; set; }
private ISessionFactory BuildSessionFactory()
{
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", this.FilePath);
return Fluently.Configure()
.Database(JetDriverConfiguration.Standard
.ConnectionString(connectionString)
.Dialect<JetDialect>()
.Driver<JetDriver>())
.Mappings(p => p.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.BuildSessionFactory();
}