when nhibernate generates a schema, what about other indexes besides PK and FK
If I let nhibernate generate the schem开发者_C百科a, what about other indexes I may put on the tables for performance reasons?
e.g. say I need to order by a datetime field allot, I may put a index on that column.
You can create a single-column unique index by specifying unique="true"
in a class property's mapping.
You can create a multi-column unique index by giving each participating property the same unique-key="foo"
value.
You can create a multi-column, non-unique index the same way, except the attribute to use is index="bar"
instead of unique-key="foo"
.
Finally, for more complex cases, you can create the index inside a <database-object>
element in the mapping file.
精彩评论