C#Nhibernate映射到查找表

时间:2016-05-18 19:03:33

标签: c# nhibernate

我很难将实体映射到另一个查找表的实体。

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,
)

和Enitites:

public class Candidate : Entity
{
    public virtual Source Source { get; set; }
}

public class Source : Entity
{
    public virtual string Name { get; set; }
}

我收到了一个错误:

  

表Candidates中的关联是指未映射的类:   Entities.Source

但我不确定如何进行映射:

public class CandidateMap : IAutoMappingOverride<Candidate>
{
    public void Override(AutoMapping<Candidate> mapping)
    {
        mapping.Map(x => x.Source);
    }
}

1 个答案:

答案 0 :(得分:0)

问题是我是从作为NHibernate命名空间一部分的Entity继承的,而不是SharpArch.NHibernate命名空间。 SharpArch对我正在使用的项目进行了一些映射。

相关问题