我的问题:
我正在尝试将Oracle.DataAccess.Client
Provider与NHibernate(Fluent)一起使用,我将其配置如下:
Fluently.Configure().Database(OracleClientConfiguration.Oracle10.Provider("Oracle.DataAccess.Client").ConnectionString(c => c.FromConnectionStringWithKey("ORACLE1"))).
我有这个错误:
"Could not load type Oracle.DataAccess.Client. Possible cause: no assembly name specified.":"
我已经使用copy local = true添加了对Oracle.Dataaccess
dll(ODAC)的引用,但错误仍然存在...
有什么建议吗?
答案 0 :(得分:4)
这是一个有效的代码片段:
public static void InitializeNHibernate()
{
var configurer = (OracleClientConfiguration.Oracle10.ShowSql().ConnectionString(c =>
c.FromConnectionStringWithKey("development"))
.DefaultSchema("myschema")
.UseReflectionOptimizer()
.Cache(c =>
c.ProviderClass<SysCacheProvider>()
.UseQueryCache()));
var cfg = Fluently.Configure()
.Database(configurer)
.Mappings(m =>
{
m.FluentMappings
.AddFromAssemblyOf<Employee>()
.Conventions.Add<OracleDateTimeTypeConvention>();
m.HbmMappings
.AddFromAssemblyOf<Employee>();
})
.ExposeConfiguration(configuration =>
{
configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
configuration.SetProperty(Environment.GenerateStatistics, "true");
configuration.SetProperty(Environment.CurrentSessionContextClass, "web");
configuration.SetProperty(Environment.CommandTimeout, "60");
});
}
如果不指定提供程序,它会自动选择Oracle DataAccess。
修改强> 不自动选择它,我只是在我的连接字符串上显示它:
<add name="development" connectionString="Data Source=XXX;User ID=yyy;Password=zzz;" providerName="Oracle.DataAccess.Client"/>