EF: object update process is not changing value of one property

后端 未结 3 1411
一个人的身影
一个人的身影 2021-01-17 16:50

my application has 2 classes: PaymentMethod & Currency (Currency is property of PaymentMethod). When my app does upda

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-17 17:25

    This issue is because of foreign key relation in not defined in PaymentMethod class. That need to be specify so specific column will be used to update and in case currency is new then that will be inserted and same code will be saved against currencycode.

    public class PaymentMethod : BaseEntity
    {
        public enum MethodTypeEnum
        {
            Creditcard,
            Virtualcard,
            Wallet
        };
        public MethodTypeEnum MethodType { get; set; }
        public int VendorId { get; set; }
        public virtual Address BillingAddress { get; set; }
    
        public string CurrencyCode {get;set;} //Replace with actual column name
    
         [ForeignKey("CurrencyCode ")]
        public virtual Currency Currency { get; set; }
    
    }
    

提交回复
热议问题