Subclass maps - No way to specify Foreign key constraint name between subclass map and class map?

Andy's Avatar

Andy

28 Jun, 2010 02:56 PM via web

HI,

It looks like there's no way to specify a FK constaint name between a subclass mapped table and the classmapped table? I've added this to our own copy of the Fluent source, and it seems like an easy addition. Is there anything wrong with it? If not, can it be added? Our DBAs quite rightfully don't like to leave the FK constraint names up for generation.

Thanks
Andy

    /// <summary>
    /// Adds a column to the key for this subclass, if used
    /// in a table-per-subclass strategy.
    /// </summary>
    /// <param name="column">Column name</param>
    public void ForeignKey(string column, string foreignKey)
    {

      KeyMapping key;

      if (attributes.IsSpecified(x => x.Key))
        key = attributes.Get(x => x.Key);
      else
        key = new KeyMapping();

      key.ForeignKey = foreignKey;

      attributes.Set(x => x.Key, key);
    }
  1. 2 Posted by mike on 27 Oct, 2010 10:09 PM

    mike's Avatar

    This would be extremely helpful if it were a part of repository...

  2. 3 Posted by Michael Dunn on 27 Oct, 2010 11:52 PM

    Michael Dunn's Avatar

    Okay well after poking around more I think I found the way that this can be accomplished without changing any of the class, and this is probably how Fluent meant for this to be handled...

    in my subclass I have:
    Key(x => {

                x.Column("IdColumn");
                x.ForeignKey("FK_My_Named_Key");
            });

    this ended up with the the column i wanted with the Foreign Key Name I wanted.

  3. 4 Posted by Andy on 28 Oct, 2010 12:39 PM

    Andy's Avatar

    Ah, they likely added Key in a later release, because I don't have that method in the build I have. Sadly, we can't upgrade either, due to some other issues.

  4. Support Staff 5 Posted by James Gregory on 05 Nov, 2010 01:47 PM

    James Gregory's Avatar

    Our issues or your issues? Anything we can do?

  5. 6 Posted by Andy on 05 Nov, 2010 02:00 PM

    Andy's Avatar

    Well the issue that has kept us from upgrading was reported in this thread: https://fluentnhibernate.tenderapp.com/discussions/help/164-convent...

    Until we get that behavior back (or a different way to acomplish the same behavior), we've been stuck on our own fork.

  6. Support Staff 7 Posted by James Gregory on 05 Nov, 2010 02:14 PM

    James Gregory's Avatar

    I didn't realise that was still an issue. I'll investigate further.

  7. 8 Posted by Andy Johnstone on 05 Nov, 2010 02:29 PM

    Andy Johnstone's Avatar

    Great, thanks!

    -----Original Message-----
    From: James Gregory [mailto:***@tenderapp.com]
    Sent: Friday, November 05, 2010 10:17 AM
    To: ***@mywebgrocer.com
    Subject: Re: Subclass maps - No way to specify Foreign key constraint name between subclass map and class map? [Help and guidance]

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    Insert the next number in this sequence: 10, 11, 12, 13, 14, ??