I currently use a table to store two different types of entities, and distinguish them using a column in the table intTypeId
Entity Company:
public CompanyMap
{
Table("tblTable");
Id(x => x.Id, "intId");
Map(x => x.TypeId, "intTypeId");
Map(x => x.Name, "strCompanyName");
...
}
Entity Person:
public PersonMap
{
Table("tblTable");
Id(x => x.Id, "intId");
Map(x => x.TypeId, "intTypeId");
Map(x => x.Name, "strPersonName");
...
}
I mapped these two models in one table, and it seems to be working well on the webpage, but it breaks some persistence specification tests, throwing exceptions.
The test of Company says that column "strPersonName"
cannot be NULL
and the test of Person says that the column "strCompanyName"
cannot be NULL
. If I remove any one map of these two, the test would pass.
Could you please tell me why this happens?