C# Automapper. Ошибка маппинга GUID и string

180
25 сентября 2019, 08:50

Есть 2 модели DocumentBLL и DocumentStatusDb

При маппинге _mapper.Map<DocumentStatusDb>(document) получаю Exception -

Error mapping types.
Mapping types:
DocumentBLL -> DocumentStatusDb
LAMS.Logic.Common.Models.Documents.DocumentBLL -> LAMS.DataAccess.Common.Models.Documents.DocumentStatusDb
Type Map configuration:
DocumentBLL -> DocumentStatusDb
LAMS.Logic.Common.Models.Documents.DocumentBLL -> LAMS.DataAccess.Common.Models.Documents.DocumentStatusDb
Property:
Id
Input string was not in a correct format.

Классы

DocumentBLL
public string Id { get; set; }
DocumentStatusDb
public int Id { get; set; }
public string DocumentId { get; set; }

Маппер

public class DocumentStatusProfile : Profile
{
   public DocumentStatusProfile()
   {
      CreateMap<DocumentBLL, DocumentStatusDb>()
        .ForMember(m => m.DocumentId, opt => opt.MapFrom(p => p.Id));
   }
}

Куски из конфигураций EF:

public class DocumentConfiguration : EntityTypeConfiguration<DocumentStatusDb>
    HasKey(x => x.Id);            
    Property(a => a.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
    Property(a => a.DocumentId).HasMaxLength(128);
public class DocumentStatusConfiguration : EntityTypeConfiguration<DocumentDb>
    HasKey(x => x.Id);

Таким образом задаю Id, который потом надо смаппить documentBLL.Id = Guid.NewGuid().ToString();

Когда Id были int все было норм.

READ ALSO
SendMessage WinApi в photoshop

SendMessage WinApi в photoshop

Пишу программу, которая должна взаимодействовать с photoshop(Это не плагин)Использовал Cursor

178
Почему спрайт в unity не перекрывает обьект?

Почему спрайт в unity не перекрывает обьект?

Ситуация следующаяЯ делаю 2д игру, там некий генератор генерирует шарики

144
ASP.NET Identity. Информация о пользователе

ASP.NET Identity. Информация о пользователе

Всем приветПишу приложение на ASP

213
&ldquo;Резкое&rdquo; применение силы к персонажу

“Резкое” применение силы к персонажу

У меня есть персонаж и враг, когда персонаж касается врага, или находится в нём, он выталкивается из него с помощью AddForce(), но это происходит...

142