I have an entity Holding which has a reference to another entity Instrument:
public class Holding { public virtual Instrument Instrument { get; set; } }
I configure the relationship using EF 6.1.3 as follows. Instrument has no reference/navigation property to Holding:
modelBuilder.Entity<Holding>().Property(h => h.Code).IsRequired(); modelBuilder.Entity<Holding>().Property(h => h.MarketValue).IsRequired(); modelBuilder.Entity<Holding>().HasRequired(h => h.Instrument);
I'm having an issue where context.Holdings.AddOrUpdate(p => p.Code, holding);
does not update the instrument on the holding record. If I change a different property, like MarketValue, MarketValue is updated, never Instrument though. If I add a holding, the Instrument is referenced correctly. It's just the update that isn't working as expected.
What am I missing?
0 comments:
Post a Comment