我们在 SQL Server 中有一个使用 Fluent Nhibernate
和 SchemaUpdate
创建的数据库,我想将其数据复制到 Postgres 数据库。
我使用相同的工具来创建数据库,但是每个没有匹配实体(例如元素)的表其名称都是小写的,并且所有列名称都是小写的。
问题是我如何告诉Fluent NHibernate
和/或SchemaUpdate
使用PascalCase
命名约定(如Sql Server)?
最佳答案
您可以使用conventions来实现这一目标。
ConventionBuilder.Class.Always(x => x.Table(x.EntityType.Name.ToLower()))
上面应该允许使用小写字母作为表名称
ConventionBuilder.Class.When(
c => c.Expect(x.TableName, Is.Not.Set), // when this is true
x => x.Table(x.EntityType.Name + "Table") // do this
)
上面比较复杂,如果没有设置表名,可以添加后缀。
关于c# - 如何更改 Fluent NHibernate 对于没有实体的表的默认命名行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30423952/