I'm having a problem using Dapper.FluentMap.Dommel.Mapping
. When I log the mapping, the system identifies that a property with the name ID already exists and throws the exception. But mapped Id belongs to another object. How can I solve this problem?
BaseEntity.cs
public abstract class BaseEntity
{
public virtual long Id { get; set; }
}
Sistema.cs
public class Sistema : BaseEntity
{
public override long Id { get; set; }
public string Nome { get; set; }
}
Arquivo.cs
public class Arquivo : BaseEntity
{
public override long Id { get; set; }
public Sistema Sistema { get; set; }
public Banco Banco { get; set; }
public List<Error> Erros { get; set; }
public string FullPath { get; set; }
public DateTime DtProcessamento { get; set; }
public int QtRegistros { get; set; }
public Decimal VlTotal { get; set; }
public int Sequencial { get; set; }
public bool isValid { get; set; }
public TipoComunicacao tipoComunicacao { get; set; }
}
ArquivoMap.cs
public class ArquivoMap : DommelEntityMap<Entities.Arquivo>
{
public ArquivoMap()
{
ToTable("Arquivo");
Map(a => a.Id).ToColumn("arqu_id").IsKey();
this.Map(a => a.Sistema.Id).ToColumn("sist_id"); //<-- Problm (1)
this.Map(a => a.Banco.Id).ToColumn("banc_id");
//this.Map(a => a.Erros).ToColumn("erro_id"); //
this.Map(a => a.FullPath).ToColumn("arqu_nm_fullPath");
this.Map(a => a.DtProcessamento).ToColumn("arqu_dt_processamento");
this.Map(a => a.QtRegistros).ToColumn("arqu_qt_registros");
this.Map(a => a.VlTotal).ToColumn("arqu_vl_total");
this.Map(a => a.Sequencial).ToColumn("arqu_id_sequencial");
this.Map(a => a.isValid).ToColumn("arqu_bt_valid");
this.Map(a => a.tipoComunicacao).ToColumn("arqu_cd_comunicacao");
}
}
RegisterMappings.cs
public static void Register()
{
FluentMapper.Initialize(config =>
{
config.AddMap(new ArquivoMap()); //<-- Call to map
config.AddMap(new BancoMap());
config.AddMap(new ErrorMap());
config.AddMap(new SistemaMap());
config.ForDommel();
});
}
Error:
System.Exception: 'Duplicate mapping detected. Property 'Id' is already mapped to column 'Id'.'