My database has a strong entity Polygon and a weak entity Vertex. I implement these entities and relation with entity and mapping classes below. but get this exception: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
public class Polygon
{
public virtual int Id { set; get; }
public virtual IList<Vertex> Vertices { set; get; }
}
public class Vertex
{
public virtual int Number { set; get; }
public virtual int X { set; get; }
public virtual int Y { set; get; }
public virtual Polygon Polygon { set; get; }
}
public class PolygonMap : ClassMap<Polygon>
{
public PolygonMap()
{
Id(x => x.Id).GeneratedBy.Identity();
HasMany(x => x.Vertices).KeyColumn("PolygonId").Inverse().Cascade.AllDeleteOrphan();
Table("Polygon");
}
}
public class VertexMap : ClassMap<Vertex>
{
public VertexMap()
{
CompositeId()
.KeyProperty(x => x.Number, "Number")
.KeyReference(x => x.Polygon, "PolygonId");
Map(x => x.X);
Map(x => x.Y);
References(x => x.Polygon).Column("PolygonId");
Table("Vertex");
}
}