Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ManyToMany Mapping using conventions #189

Open
faboudib opened this issue Nov 6, 2012 · 0 comments
Open

ManyToMany Mapping using conventions #189

faboudib opened this issue Nov 6, 2012 · 0 comments

Comments

@faboudib
Copy link

faboudib commented Nov 6, 2012

I am using FluentNH with automapping and conventions. I set up a Many-to-Many convention as such:

    public class HasManyToManyConvention : IHasManyToManyConvention
    {
        public void Apply(IManyToManyCollectionInstance instance)
        {
            instance.Key.Column(instance.EntityType.Name + "Id");
            instance.Relationship.Column(instance.Relationship.StringIdentifierForModel + "Id");
        }
    } 

Assuming these are my tables:
User(Id,Username,Password),
Role(Id,Name)

Upon database generation, the associative table is being generated fine:
UserInRole(UserId,RoleId)

However, it has no composite primary key set (containing UserId and RoleId). Any way to set this from the convention?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant