【发布时间】:2010-11-04 14:32:47
【问题描述】:
我想在一个新项目中使用DDD 并首先对我的类进行建模,然后根据类库生成数据库模式。我的计划是使用 NHibernate hbm2ddl 工具 SchemaExport 来做到这一点。
问题是我无法让 SchemaExport 工作,因为它让我陷入了一个奇怪的 catch-22 问题。SchemaExport 需要一个 Configuration 对象,该对象本身需要一个有效的 NHibernate 配置文件作为以及一组数据库映射。
这里的第 22 个问题是,当我执行 Configure() 时,它会抱怨 "Could not determine the name of the table for entity 'MyEntity'; remove the 'table' attribute or assign a value to it." 所以 Configure() 方法需要表存在,而 SchemaExport 应该基于 @987654329 创建它@ 我无法创建,因为该表不存在。
那么,我到底应该如何创建一个有效的 NHibernate Configuration,其中包含 SchemaExport 实际做一些有用的事情所需的映射,而没有 Configure() 抛出并抱怨它找不到表用SchemaExport 创建?是否有一个“模式”我可以设置 Configuration 对象,这样它就不会检查数据库是否存在给定的表,或者我需要做些什么吗?
【问题讨论】:
标签: .net nhibernate hbm2ddl schemaexport