Pefrect. Thank you. For the benefit of others, here is the convention
that I am using:

public class OneToManyConvention : IHasManyConvention
    {
        public bool Accept(IOneToManyPart target)
        {
            return true;
        }

        public void Apply(IOneToManyPart target)
        {
            target.Cascade.All().WithForeignKeyConstraintName("FK__" +
target.Member.DeclaringType.Name + target.Member.Name);
        }
    }

On Apr 29, 6:44 am, Hudson Akridge <[email protected]> wrote:
> Actually, as a temporary workaround, here's a patch I put together that will
> give you the ability to specify foreign keys in conventions for OneToMany,
> ManyToMany, ManyToOne, and OneToOne mappings. There's a pretty large change
> coming down the pipe from James and Paul here shortly, so once they've got
> that committed, I'll see what I can do about getting something like this
> patch pushed into trunk. For now, enjoy! :)
>
> On Tue, Apr 28, 2009 at 8:03 AM, Hudson Akridge 
> <[email protected]>wrote:
>
> > Right now, the conventions and I believe the automapping stuff is all based
> > on interfaces. The interfaces are unfortunately a bit behind the curve
> > versus the concrete class definitions. i.e. the concretes have 100% of the
> > object functionality, while the interface may only have 40-60%. That's one
> > of the things that we need to be more consistent with.
> > As we clean those up, you'll see methods become available to you.
> > Specifying FK constraints through the interface is top on my list :) .
>
> > On Tue, Apr 28, 2009 at 7:46 AM, MaggiePlusPlus <[email protected]
> > > wrote:
>
> >> Do you mean the constraint name created in the schema?  I also would
> >> like to know how to do this.  I have a convention to name the FK but
> >> need a way to do the relationship.
>
> >> On Apr 28, 7:21 am, liam <[email protected]> wrote:
> >> > Is there a way to specify the name of foreign keys when using
> >> > automapping? I mean the foreign key, not the foreign key column. I
> >> > want the foreign keys to be generated with predictable names instead
> >> > of the random ones.
>
> >> > Thanks,
> >> > Liam.
>
>
>
>  ForeignKeyConstraintConvention.patch
> 6KViewDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to