对象引用未设置为对象实例 nhibernate 配置 buildsessionfactory
hiii 我在为流畅的 nhibernate 应用程序运行测试时收到此错误。不知道是什么原因造成的。
这是我的映射和我的域
public class Employee
{
public virtual String emp_code { get; set; }
public virtual String emp_name { get; set; }
public virtual String expertise_id { get; set; }
public virtual String grade_id { get; set; }
public virtual String role_id { get; set; }
public virtual String Status { get; set; }
public virtual String email_id { get; set; }
}
这是我的映射
public class EmployeeMap:ClassMap<Employee>
{
public EmployeeMap()
{
Table("employee_master");
Id(x => x.emp_code);
Map(x => x.emp_name);
Map(x => x.expertise_id);
Map(x => x.grade_id);
Map(x => x.role_id);
Map(x => x.Status);
Map(x => x.email_id);
}
}
和我的测试类:
public class Test
{
private ISessionFactory sessionFactory;
[Test]
public void Can_generate_schema()
{
sessionFactory = Fluently.Configure(cfg).Database(MsSqlConfiguration.MsSql2008.ConnectionString(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<EmployeeMap>()).BuildSessionFactory();
}
}
有人可以告诉我为什么我会收到错误吗???什么可能导致它?
hiii i am getting this error while running test for my fluent nhibernate application. not sure whats causing it .
here are my mappings and my domain
public class Employee
{
public virtual String emp_code { get; set; }
public virtual String emp_name { get; set; }
public virtual String expertise_id { get; set; }
public virtual String grade_id { get; set; }
public virtual String role_id { get; set; }
public virtual String Status { get; set; }
public virtual String email_id { get; set; }
}
this is my mapping
public class EmployeeMap:ClassMap<Employee>
{
public EmployeeMap()
{
Table("employee_master");
Id(x => x.emp_code);
Map(x => x.emp_name);
Map(x => x.expertise_id);
Map(x => x.grade_id);
Map(x => x.role_id);
Map(x => x.Status);
Map(x => x.email_id);
}
}
and my test class :
public class Test
{
private ISessionFactory sessionFactory;
[Test]
public void Can_generate_schema()
{
sessionFactory = Fluently.Configure(cfg).Database(MsSqlConfiguration.MsSql2008.ConnectionString(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<EmployeeMap>()).BuildSessionFactory();
}
}
can someone tell me why am i getting the error ??? what might cause it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查以确保 cfg 已在上面初始化。
Check to make sure cfg is initialized above.