2016-05-18 7 views
2

Ich habe eine schwierige Zeit Zuordnung einer Entität zu einer anderen Entität, die eine Nachschlagetabelle ist.C# Nhibernate Mapping zu Lookup-Tabelle

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

Und Enitites:

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

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

Ich erhalte eine Fehlermeldung:

An association from the table Candidates refers to an unmapped class: Entities.Source

Aber ich bin nicht sicher, wie man über die Zuordnung gehen:

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

Antwort

0

Die Problem war, dass ich von der Entität erbte, die ein Teil von NH war ibernate-Namespace anstelle des SharpArch.NHibernate-Namespace. SharpArch führt eine Zuordnung durch, in der das Projekt, in dem ich arbeitete, verwendet wurde.