EF外键添加
关于外键添加,直接使用赋值的方式。
public partial class YXTDemand : FullAuditedEntity<int, User> { public virtual YXTOrigin Origin { get; set; } } public partial class YXTOrigin : FullAuditedEntity<int, User> { public virtual ICollection<YXTDemand> YXTDemands { get; set; } }
var entity= var entity = input.MapTo<YXTDemand>(); var merchandise = await _yXTMerchandiseRepository.GetAsync(Merchandise_Id); entity.SpecifiedOrigin = origin.OriginName; await _yXTDemandRepository.InsertAsync(entity);