开发者

Fluent NHibernate - Mapping error, XML Validation, Invalid/Incomplete configuration

I'm fairly new to NH and FNH. I want to map a List of longs, and I'm getting the error:

An invalid or incomplete configuration was used while creating a SessionFactory.

Double inner Exception:

{"(XmlDocument)(15,8): XML validation error: The element 'list' in namespace 'ur开发者_Python百科n:nhibernate-mapping-2.2' has invalid child element 'one-to-many' in Namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'loader, sql-insert, sql-update, sql-delete, sql-delete-all, filter' in Namespace 'urn:nhibernate-mapping-2.2'."}

My entity:

public class XPTable
{
    public virtual int I3D { get; set; }
    public virtual IList<long> XPRequired { get; set; }

    public XPTable()
    {
        XPRequired = new List<long>();
    }
}

My Mapping:

public class XPTableMaps : ClassMap<XPTable>
{
    public XPTableMaps()
    {
        Table("XPTable");

        Id(id => id.I3D);

        //this line causes the error
        HasMany<long>(many => many.XPRequired).AsList().Element("XPRequired");
    }
}

I use NHibernate 3.1.0, FNH 1.0

It's definitely the HasMany mapping that's causing the problem, because when I comment it out, the program runs just fine. The I3D column in the SQL 2008 table is the identity, the names/types of the table and the columns match the mapping. If I leave out the .AsList(), then the error message stays the same except that it refers to 'bag' instead of 'list'. Adding Inverse() and/or Cascade.Whatever() has no effect either.

Any ideas please?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜