Automapper c# не работает Ignore()
Есть у меня свой класс пользователя, который представляет объект в БД
public class AppUser
{
public int Id { get; set; }
public int TgId { get; set; }
public bool IsBot { get; set; }
public string Role { get; set; }
public string TgLangCode { get; set; }
public string TgUserName { get; set; }
public string TgFirstName { get; set; }
public string TgLastName { get; set; }
public string TgPhone { get; set; }
public string VCard { get; set; }
public string PayloadId { get; set; }
public AppUserSetting UserSetting { get; set; }
}
И есть класс, который предоставляет библиотека TelegrammBotApi
//
// Summary:
// This object represents a Telegram user or bot.
[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
public class User : IEquatable<User>
{
public User();
//
// Summary:
// Unique identifier for this user or bot
[JsonProperty(Required = Required.Always)]
public int Id { get; set; }
//
// Summary:
// True, if this user is a bot
[JsonProperty(Required = Required.Always)]
public bool IsBot { get; set; }
//
// Summary:
// User's or bot's first name
[JsonProperty(Required = Required.Always)]
public string FirstName { get; set; }
//
// Summary:
// Optional. User's or bot's last name
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public string LastName { get; set; }
//
// Summary:
// Optional. User's or bot's username
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Username { get; set; }
//
// Summary:
// Optional. IETF language tag of the user's language
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public string LanguageCode { get; set; }
//
// Summary:
// Optional. True, if the bot can be invited to groups. Returned only in getMe
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? CanJoinGroups { get; set; }
//
// Summary:
// Optional. True, if privacy mode is disabled for the bot. Returned only in getMe
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? CanReadAllGroupMessages { get; set; }
//
// Summary:
// Optional. True, if the bot supports inline queries. Returned only in getMe
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? SupportsInlineQueries { get; set; }
public override bool Equals(object obj);
public bool Equals(User other);
public override int GetHashCode();
public override string ToString();
//
// Summary:
// Compares two users for equality
//
// Parameters:
// lhs:
// Left-hand side user in expression
//
// rhs:
// Right-hand side user in expression
//
// Returns:
// true if users are equal, otherwise false
public static bool operator ==(User lhs, User rhs);
//
// Summary:
// Compares two users for inequality
//
// Parameters:
// lhs:
// Left-hand side user in expression
//
// rhs:
// Right-hand side user in expression
//
// Returns:
// true if users are not equal, otherwise false
public static bool operator !=(User lhs, User rhs);
Что мне необходимо сделать? Просто смаппить библиотечный класс User в мой класс AppUser, при условии, что AppUser.Id должен остаться не тронутым(проигнорирован при маппинге). Я перепробовал кучу методов проигнорить это свойство, но Автомаппер почему-то упрямо продалжает маппить User.Id в AppUser.Id
CreateMap<User, AppUser>()
.ForMember(x => x.TgId, x => x.MapFrom(s => s.Id))
.ForMember(x => x.IsBot, x => x.MapFrom(s => s.IsBot))
.ForMember(x => x.TgLangCode, x => x.MapFrom(s => s.LanguageCode))
.ForMember(x => x.TgUserName, x => x.MapFrom(s => s.Username))
.ForMember(x => x.TgFirstName, x => x.MapFrom(s => s.FirstName))
.ForMember(x => x.TgLastName, x => x.MapFrom(s => s.LastName))
// ниже указаны все способы проигнорить `Id` которые я использовал и которые не сработали.
.ForPath(x => x.Id, s => s.Ignore())
.ForMember(x => x.Id, s => s.Ignore())
.ForSourceMember(x => x.Id, s => s.DoNotValidate())
.ForAllOtherMembers(x => x.Ignore());