Q:

Nhibernate ComposedId on intermediate table

I want to have a intermediate table with only two foreign keys (as a ComposedId). 
But NHibernate is automatically creating a "id" property. 
I have the following classes
public class Lace
{
    public virtual int Id { get; set; }
    public virtual string Hostname { get; set; }

    public virtual IList<LaceHasCard> LaceHasCards { get; set; }
}

public class Card
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }

    public virtual IList<LaceHasCard> LaceHasCards { get; set; }
}

and this manually created intermediate table
public class LaceHasCard
{
    public virtual Card Card { get; set; }
    public virtual Lace Lace { get; set; }
}

Mappings
public LaceMapping()
{
    Id(x => x.Id, map => map. Generator(Generators. Native));
    Property(x => x.Hostname);

    Bag(x => x.LaceHasCards, col =>
    {
        col. Key(k => k.Column("LaceId"));
        col. Inverse(true);
    }, r => r.OneToMany());
}

public CardMapping()
{
    Id(x => x.Id, map => map. Generator(Generators. Native));
    Property(x => x.Name);

    Bag(x => x.LaceHasCards, col =>
    {
        col. Key(k => k.Column("CardId"));
        col. Inverse(true);
    }, r => r.OneToMany());
}

intermediate table mapping
public LaceHasCardMapping()
{
    //ComposedId(map =>
    //{
    //    map. Property(x => x.Card. Id, a =>
    //    {
    //        a.Column("CardId");
    //    });
    //    map. Property(x => x.Lace. Id, a =>
    //    {
    //        a.Column("LaceId");
    //    });
    //});

    ManyToOne(x => x.Card, map =>
    {
        map. Column("CardId");
    });

    ManyToOne(x => x.Lace, map =>
    {
        map. Column("LaceId");
    });
}

If I create the schema with the ComposedId commented out, NHibernate will create a "id" property in the table. 
CREATE TABLE [dbo].[LaceHasCard] (
    [id]     INT NOT NULL,
    [CardId] INT NULL,
    [LaceId] INT NULL,
    PRIMARY KEY CLUSTERED ([id] ASC),
    CONSTRAINT [FKDC6D54711CD160AE] FOREIGN KEY ([CardId]) REFERENCES [dbo].[Card] ([Id]),
    CONSTRAINT [FKDC6D547151F8AF85] FOREIGN KEY ([LaceId]) REFERENCES [dbo].[Lace] ([Id])
);

If I try to create the schema with the ComposedId, I get the following error message:

Unable to instantiate mapping class (see InnerException):
  EmpLaceMgmt. Models. Mappings. LaceHasCardMapping

What would be the right way to tell NHibernate to create a composed Id? 

A:

Let me give you suggestion, just my point of view - do not use composite id. Use standard primary key in DB and its C# / entity representation as Id { get; set; }
Chapter 24.  Best Practices

...
Declare identifier properties on persistent classes. 
NHibernate makes identifier properties optional.  There are all sorts of reasons why you should use them.  We recommend that identifiers be 'synthetic' (generated, with no business meaning) and of a non-primitive type.  For maximum flexibility, use Int64 or String.  

See also more about synthetic, surrogate keys at wiki. 
From my experience, we should not be worry about having pairing object like this:
public class LaceHasCard
{
    public virtual int Id { get; set; } // the key
    public virtual Card Card { get; set; }
    public virtual Lace Lace { get; set; }
}

Because later it would become so easy to access it:
session. Get<LaceHasCard>(id)

And also to use it in Subqueries (for filtering Card with Laces and vice versa)
One column in DB, autogenerated, should not have any extra bad impact.  But handling such table is a bit (a lot) easier...
So, summary, my suggestion would be, make all entities first level citizens, with full rights (including synthetic/surrogate key)

