Search code examples
asp.net-mvcnhibernatefluent-nhibernatenhibernate-mappingfluent-nhibernate-mapping

ASP.NET error with Nhibernate


I have LineBrand table which has many LineBrandLocalization. When I map it like

 HasMany(x => x.LineBrandLocalizations)
.KeyColumn("line_brand_id")
.Access.CamelCaseField(Prefix.Underscore)
.Cascade.AllDeleteOrphan()
.Fetch.Subselect()
.Inverse();

and LineBrandLocalizations is

public virtual IEnumerable<LineBrandLocalization> LineBrandLocalizations
{
    get { return _lineBrandlocalizations; }
}


private IList<LineBrandLocalization> _lineBrandlocalizations = new List<LineBrandLocalization>();

I get the error

NHibernate.PropertyNotFoundException: Could not find field '_lineBrandLocalizations' in class 'LineBrand'.

What is wrong with it?


Solution

  • The naming is essential. Your field is

    _lineBrandlocalizations // see the lower l localizations
    

    while it should be

    _lineBrandLocalizations // see the upper L Localizations