&引用;无效的对象名称";fluent nhibernate配置中存在错误
我在应用程序中使用的是fluent nhibernate,我还使用sql server 2012。这是我的配置:&引用;无效的对象名称";fluent nhibernate配置中存在错误,nhibernate,fluent-nhibernate,Nhibernate,Fluent Nhibernate,我在应用程序中使用的是fluent nhibernate,我还使用sql server 2012。这是我的配置: public class SessionFactory { private static ISessionFactory _sessionFactory; public static string ConnectionString { get { return ConfigurationManager.
public class SessionFactory
{
private static ISessionFactory _sessionFactory;
public static string ConnectionString
{
get { return ConfigurationManager.ConnectionStrings["ECommerceConnectionString"].ToString(); }
}
private static void Initialize()
{
var config = Fluently.Configure().Database(
MsSqlConfiguration
.MsSql2008
.ConnectionString(ConnectionString).ShowSql().Dialect<MsSql2012Dialect>());
_sessionFactory = config.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ContactMapping>()).BuildSessionFactory();
}
private static ISessionFactory GetSessionFactory()
{
if (_sessionFactory == null)
Initialize();
return _sessionFactory;
}
private static ISession GetNewSession()
{
return GetSessionFactory().OpenSession();
}
public static ISession GetCurrentSession()
{
var sessionStorageContainer = SessionStorageFactory.GetStorageContainer();
var currentSession = sessionStorageContainer.GetCurrentSession();
if (currentSession == null)
{
currentSession = GetNewSession();
sessionStorageContainer.Store(currentSession);
}
return currentSession;
}
}
公共类SessionFactory
{
私人静态ISessionFactory_sessionFactory;
公共静态字符串连接字符串
{
获取{return ConfigurationManager.connectionString[“电子商务连接字符串”].ToString();}
}
私有静态void Initialize()
{
var config=fluntly.Configure().Database(
MSSQL配置
.MsSql2008
.ConnectionString(ConnectionString.ShowSql().dial());
_sessionFactory=config.Mappings(m=>m.FluentMappings.AddFromAssemblyOf()).BuildSessionFactory();
}
私有静态ISessionFactory GetSessionFactory()
{
if(_sessionFactory==null)
初始化();
返回工厂;
}
私有静态ISession GetNewSession()
{
返回GetSessionFactory().OpenSession();
}
公共静态ISession GetCurrentSession()
{
var sessionStorageContainer=SessionStorageFactory.GetStorageContainer();
var currentSession=sessionStorageContainer.GetCurrentSession();
如果(currentSession==null)
{
currentSession=GetNewSession();
sessionStorageContainer.Store(当前会话);
}
返回当前会话;
}
}
虽然我使用的是MsSql2012Dialect
,但仍然存在sql server兼容性错误,请问如何修复此错误 你真的应该使用
Fluently.Configure()
.Database(
MsSqlConfiguration
.MsSql2012
.ConnectionString(conString)
.ShowSql)
对我来说很流利
“无效对象名”错误通常引用SQL异常,例如表不存在或类似的情况。。。完整堆栈跟踪/错误消息会有所帮助。您能发布完整异常吗?“无效对象名”看起来太一般化了