Convention for Index creation

Michael Hallock's Avatar

Michael Hallock

03 Nov, 2010 05:04 PM via web

Question: I understand the reasoning for not automatically creating
indexes on Foreign Keys, but if I WANT Foreign Keys to have their
Indexes automatically generated at SchemaExport or SchemaUpdate time,
is there a way to do that (Specifically for HasMany and HasManyToMany
relations)?

I've been looking for a way to do this by convention, as in my
specific case I would want this to happen at all times...
I saw this:

http://stackoverflow.com/questions/607935/generate-table-indexes-usin...
http://stackoverflow.com/questions/1786898/fluent-nhibernate-and-sche...

One of those could do it, but I'm looking for a way to do it by
convention instead of either attribute decoration on the property or
specified inline on the mappings files.

Also, I'm not sure if the first way (attribute) would work for a
HasManyToMany or HasMany.

I've already gone through and MANUALLY added all these indexes, but
this is more for my library of conventions for our future development
projects...

  1. Support Staff 2 Posted by James Gregory on 05 Nov, 2010 01:26 PM

    James Gregory's Avatar

    How have you manually added the indexes? Have you tried doing the same through an IHasManyConvention?

  2. 3 Posted by Michael Hallock on 05 Nov, 2010 06:34 PM

    Michael Hallock's Avatar

    Well, manually created as in go into SQL server and manually add them all to the columns they should be on... :-)

    I was just looking for a way to do this on green field projects automagically in the future.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is 14 minus 4?