Subclass maps - No way to specify Foreign key constraint name between subclass map and class map?
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);
}
2 Posted by mike on 27 Oct, 2010 10:09 PM
This would be extremely helpful if it were a part of repository...
3 Posted by Michael Dunn on 27 Oct, 2010 11:52 PM
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 => {
this ended up with the the column i wanted with the Foreign Key Name I wanted.
4 Posted by Andy on 28 Oct, 2010 12:39 PM
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.
Support Staff 5 Posted by James Gregory on 05 Nov, 2010 01:47 PM
Our issues or your issues? Anything we can do?
6 Posted by Andy on 05 Nov, 2010 02:00 PM
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.
Support Staff 7 Posted by James Gregory on 05 Nov, 2010 02:14 PM
I didn't realise that was still an issue. I'll investigate further.
8 Posted by Andy Johnstone on 05 Nov, 2010 02:29 PM
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]