You are getting those duplicate columns because they are in the XML that FNH
is passing over to NHibernate.

Since this is coming from the mappings, you might have better luck on the
Fluent NHibernate list.


On Wed, Aug 25, 2010 at 2:50 PM, [email protected] <
[email protected]> wrote:

> I really don't want to dump a bunch of code in here, but I have no
> choice. Below are some "navigation element only" entities and their
> maps, as they sit. SchemaExport works and generates the db, but it's
> wrong! All the pivot tables have duplicate ids, using both my
> convention and the default. I'll give an example of that last. Take a
> look and tell me what I'm doing wrong.
>
> namespace SchemaGenerator.Models
> {
>
>    // used to associate a role with a forum
>    // and add role permission overrides
>    public class Mask : Entity
>    {
>
>        // references - passed in via constructor
>        public virtual Role Role { get; set; }
>        public virtual Forum Forum { get; set; }
>
>        // maintains a list of permissions - add - remove
>        private IList<Permission> permissions = new
> List<Permission>();
>        public virtual IEnumerable<Permission> Permissions { get
> { return permissions; } }
>
>    }
>
>    public class Permission : Entity
>    {
>
>        // contains a list of masks - read only
>        private IList<Mask> masks = new List<Mask>();
>        public virtual IEnumerable<Mask> Masks { get { return
> masks; } }
>
>        // contains a list of moderators - read only
>        private IList<Moderator> moderators = new List<Moderator>();
>        public virtual IEnumerable<Moderator> Moderators { get
> { return moderators; } }
>
>        // contains a list of roles - read only
>        private IList<Role> roles = new List<Role>();
>        public virtual IEnumerable<Role> Roles { get { return
> roles; } }
>
>    }
>
> }
>
> using FluentNHibernate.Mapping;
>
> namespace SchemaGenerator.Models.Mapping
> {
>
>    public class MaskMap : ClassMap<Mask>
>    {
>
>        public MaskMap()
>        {
>
>            Id(x => x.Id);
>
>            // references - passed in via constructor
>            References<Role>(x => x.Role);
>            References<Forum>(x => x.Forum);
>
>            // maintains a list of permissions - add - remove
>            HasManyToMany<Permission>(x => x.Permissions)
>                .Table("MaskPermissions"); // no joining entity, need
> custom table name
>
>        }
>
>    }
>
>    public class PermissionMap : ClassMap<Permission>
>    {
>
>        public PermissionMap()
>        {
>
>            Id(x => x.Id);
>
>            // contains a list of masks - read only
>            HasManyToMany<Mask>(x => x.Masks)
>                .Table("MaskPermissions"); // no joining entity, need
> custom table name
>
>            // contains a list of moderators - read only
>            HasManyToMany<Moderator>(x => x.Moderators)
>                .Table("ModeratorPermissions"); // no joining entity,
> need custom table name
>
>            // contains a list of roles - read only
>            HasManyToMany<Role>(x => x.Roles)
>                .Table("RolePermissions"); // no joining entity, need
> custom table name
>
>        }
>
>    }
>
> }
>
> What happens on generation is that it generate the MaskPermissions
> table with the following fields:
>
> MaskId - ok
> Permission_id - not ok...
> PermissionId - ok
> Mask_id - not ok...
>
> Why is it added two additional fields that don't match my convention
> files?
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to