sql server - nHibernate and SQLServer: can I declare indexes from the mapping, or do I have to create them separately -


i have simple mapping file:

<class name="comment">   <id name="id" generator="increment" />   <property name="knowledgeid" /> </class> 

where "knowledgeid" foreign key table. indexed performance reasons. know can create index in sql server management studio , linking through name:

  <property name="knowledgeid" index="ix_knowledgecomment_id" /> 

but wondering if can reach same goal through nhibernate configuration.

so, what's standard practice in defining indexes nhibernate-generated tables?

yes can create indices or unique contraints nhibernate. here's syntax unique constraints using mapping code

public agencymap() {     property(x => x.name, m =>      {          m.uniquekey("uc_agencyname");         m.index("ix_agencyname");         m.notnullable(true);      });     property(x => x.ori); 

here's link example using multiple column index

how create index on multiple fields using nhibernate 3.2 mapping code?


Comments