【问题标题】:NHibernate in the configuration can not see anythingNHibernate在配置中什么都看不到
【发布时间】:2011-10-23 01:16:46
【问题描述】:

我需要有关配置 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 似乎无法“拾取”映射文件。为什么?

提前致谢!

【问题讨论】:

    标签: c# nhibernate configuration nhibernate-mapping


    【解决方案1】:

    由于映射文件位于单独的文件夹中 - nhibernate 无法看到它们。由Configuration.AddDirectory()决定。

    【讨论】:

      猜你喜欢
      • 2018-07-21
      • 1970-01-01
      • 1970-01-01
      • 2012-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多