问题描述
我们正在尝试将解决方案从本地数据库迁移到云解决方案,尤其是在这种情况下迁移到Azure SQL数据库。我们正在使用NHibernate,我们发现了一些块
- 连接字符串不支持身份验证,这意味着我无法提供连接的用户名和密码
- 连接字符串不支持访问令牌,类似于第1点
基于此,我们必须从NHibernate提供的ADO.NET连接转移到User提供的ADO.NET连接。
注意:我们正在使用AAD SPN连接到数据库。我们不允许使用SQL身份验证
下面是我们正在使用的代码
public class HibernateUtil
{
private static ISessionFactory _sessionFactory;
private static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
Configuration objConfiguration = new Configuration();
objConfiguration.SetProperty("dialect","NHibernate.Dialect.MsSqlAzure2008Dialect");
//Add all Entities
objConfiguration.AddAssembly(typeof(<entity/beam/domain>).Assembly);
//Here is where we get the error
_sessionFactory = objConfiguration.BuildSessionFactory();
}
return _sessionFactory;
}
}
public static ISession OpenSession()
{
//deprecated
return SessionFactory.OpenSession(<ADO.NET Connection>);
//or
return SessionFactory.WithOptions().Connection(<ADO.NET Connection>).OpenSession()
}
}
错误消息:
用户必须提供ADO.NET连接-NHibernate不是 创建它。
如何在_sessionFactory.BuildSessionFactory()之前提供ADO.NET连接? 我们正在检查以下https://nhibernate.info/doc/nhibernate-reference/session-configuration.html
但是关于BuildSessionFactory的此问题尚不清楚
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)