✅ MongoDB Driver error when reading using interface

Hi guys, I'm having trouble trying to read from my mongodb database, I used to use one class, but now it is one interface and other classes that can have more properties than the interface.
c#
public interface IEntity {
    public Guid Id { get; set; }
    public Guid? TenantId { get; set; }
}

public interface IAccount : IEntity
{
    public string Type { get; set; }
    public string Name { get; set; }
    public Currency Currency { get; set; }
    public DateTime CreatedAt { get; set; }
    public List<CurrencyBalance> CurrenciesBalance { get; set; }
    public DateTime? UpdatedAt { get; set; }
}

public class CreditCard : IAccount
{
    public Guid? AutomaticDebitAccountId { get; set; } = null;
    public required decimal Limit { get; set; }
    public override string Type { get; set; } = AccountType.CreditCard;
    public DateTime ClosingDate { get; set; }
    public DateTime ExpirationDate { get; set; }
}

public class DebitCard : IAccount
{
    public required override string Type { get; set; } = AccountType.Bank;
}

On my repository I'm reading using the IAccount interface and on my code whenever I need I eventually cast to CreditCard or DebitCard, but it is giving me this error: Error during MainService.Domain.Interfaces.IAccount GetAsync: Unable to determine actual type of object to deserialize for interface type MainService.Domain.Interfaces.IAccount.
Was this page helpful?