I was following Bruno's excellent article for one-to-one mapping in fluent Nhibernate. However I ran into a small trouble while mapping the private entities with an error which is not clear. Here are my entities, mapping and error:
Entities
public class Student
{
public virtual String Studentid { get; set; }
public virtual Address Address { get; set; }
}
public class Address
{
private String StudentId { get; set; }
private Student Student { get; set; }
public Address(Student student)
{ Student = student; }
}
Mapping :
public StudentMap()
{
Id(x => x.Studentid).GeneratedBy.Assigned();
HasOne(x => x.Address).Cascade.All();
}
public AddressMap()
{
Id(x=> Reveal.Member<Address>("StudentId"))
.GeneratedBy.Foreign("Student");
HasOne( x=> Reveal.Member<Address,Student>("Student"))
.Constrained()
.ForeignKey();
}
Now when I am trying to run it it's giving error as:
Could not determine type for: System.Linq.Expressions.Expression
1[[System.Func
2[[CastleTest.Domain.Address, CastleTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, for columns: NHibernate.Mapping.Column(Member)
Why is this error happening?