Problem when saving data "ex = {" An entity object can not be referenced by multiple instances of IEntityChangeTracker. "}
- public class Transactions
- {
- [Key]
- public long Id { get; set; }
- public string Url { set; get; }
- public bool? Showsender { get; set; }
- public virtual PaymentStatus PaymentStatusItem { get; set; }
- public string Trackingnumber { set; get; }
- public DateTime? Executiondatetime { set; get; }
- public virtual Account SourceAccount { set; get; }
- public virtual Account DestinationAccount { set; get; }
- public Decimal? Amount { set; get; }
- public string Currency { set; get; }
- public string Type { set; get; }
- public string Status { set; get; }
- public string Description { set; get; }
- public decimal? CurrentBalance { get; set; }
- public decimal? Balance { get; set; }
- public virtual TransactionType TransactionTypeItem { get; set; }
- public virtual Account DestinationAccountItem { get; set; }
- public virtual Account SourceAccountItem { get; set; }
- }
- public bool Save(Transactions tran)
- {
- try
- {
- db.transactons.Add(tran);
- db.SaveChanges();
- return true;
- }
- catch (Exception ex)
- { } return false;
- }
I tried but I couldn't find a solution to this problem, please help.