2

I am trying to use a Fluent NHibernate naming convention to make my foreign keys follow this naming standard:

fk<table name>_<foreign table name>_<underscore delimited column list>

...but using the conventions, I can't seem to get the table names. I can do something like this:

var fkIndexConvention = ConventionBuilder.Reference.Always(x =>
    x.ForeignKey(string.Format("ix{0}_{1}", x.Class.Name, x.Property.Name)));

which seems kinda close, but I'd really like to reference the two related tables and the involved column(s). How can I do this?

Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254
  • ... that's a heck of a stretch to call that a duplicate. – Jeremy Holovacs Jan 29 '13 at 19:03
  • Why? As you, the OP wants to have the foreign table's name in its key. Furthermore, it shows the only way this would be possible at all: Deriving from `ForeignKeyConvention`. – Daniel Hilgarth Jan 29 '13 at 20:04
  • The answers may be related to some degree, but reading that question certainly did not give me a useable answer to my own; classifying this as a duplicate question when different things are asked for and answered simply because they may be abstractly related comfortably fits my definition of a "stretch". – Jeremy Holovacs Jan 29 '13 at 21:12
  • That's why four others also need to mark your question as a duplicate before my action has any more effect than just being a comment. Actually, I marked it as a duplicate, because I wanted to help you but didn't have the time to actually answer your question with a well-researched answer. Marking it as a duplicate seemed to be the easiest way to give you at least *some* information. Take it or leave it. – Daniel Hilgarth Jan 29 '13 at 22:49

0 Answers0