I'm having a difficult time mapping an entity to another entity that is a lookup table.
create table Sources
(
SourceId identity(1,1) primary key not null,
Name [nvarchar](255) NULL,
)
create table Candidates
(
CandidateId int identity(1,1) primary key not null,
SourceId int references Sources(SourceId) NULL,
)
And Enitites:
public class Candidate : Entity
{
public virtual Source Source { get; set; }
}
public class Source : Entity
{
public virtual string Name { get; set; }
}
I'm getting a error:
An association from the table Candidates refers to an unmapped class: Entities.Source
But I am unsure how to go about the mapping:
public class CandidateMap : IAutoMappingOverride<Candidate>
{
public void Override(AutoMapping<Candidate> mapping)
{
mapping.Map(x => x.Source);
}
}
The problem was I was inheriting from the Entity that was part of NHibernate namespace, instead of the SharpArch.NHibernate namespace. SharpArch does some mapping that the project I was working in was using.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.