NHibernate中的配置看不到任何东西
我需要配置 NHibernate 方面的帮助。在我的解决方案中有几个项目:第一个包含代码实体,第二个包含映射文件“*.hbm.xml”。
我是通过代码来配置的。如下:
Configuration config = new Configuration().
Proxy(proxy => proxy.ProxyFactoryFactory<ProxyFactoryFactory>()).
DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.ConnectionString = @"Data Source=(local)\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=True;Pooling=False";
db.BatchSize = 100;
}).AddAssembly("MyProject.DAL.Mappings");
这段代码不会在数据库中创建表:
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.Create(false, true);
这段代码创建一个空文件:
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.SetOutputFile(@"db.sql").Execute(false, false, false);
看来 NHibernate 无法“拾取”映射文件。为什么?
提前致谢!
I need help with configuring NHibernate. In my solution has several projects: first contains the code entity, second contains the mapping files "*.hbm.xml".
I configure through code. Here it is:
Configuration config = new Configuration().
Proxy(proxy => proxy.ProxyFactoryFactory<ProxyFactoryFactory>()).
DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.ConnectionString = @"Data Source=(local)\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=True;Pooling=False";
db.BatchSize = 100;
}).AddAssembly("MyProject.DAL.Mappings");
This code does not create tables in the database:
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.Create(false, true);
This code creates an empty file:
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.SetOutputFile(@"db.sql").Execute(false, false, false);
It seems that NHibernate can not "pick up" mapping files. Why?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于映射文件位于单独的文件夹中 - nhibernate 无法看到它们。由
Configuration.AddDirectory()
决定。Since the mapping files were in a separate folder - nhibernate could not see them. Decided by
Configuration.AddDirectory()
.