You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
As far as CLR types are not tracked by ef core (#1117)
What's the proper way of updating inner entities?
models.cs
public class CouponConfiguration
{
public int MaxEvents { get; set; }
}
public class Configurations
{
public int Id { get; set; }
public CouponConfiguration Coupon { get; set; }
public int CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
}
And that action causes exception: System.InvalidOperationException: The entity type 'CouponConfiguration' was not found. Ensure that the entity type has been added to the model.
It`s possible to bypass that exception when setting the whole entity to state modified, then update works.
context.Entry(obj).State = EntityState.Modified;
But doing that will cause ef core to update ALL properties, instead of only one inner object.
Is it possible to bypass that limitation\exception somehow?
Thanks,
Stas
The text was updated successfully, but these errors were encountered:
Going over old issues and came across this - sorry I haven't responded earlier.
CouponConfiguration isn't an entity type known by EF Core, since it's mapped to a json column. In other words, EF Core doesn't track the individual properties contained inside CouponConfiguration.
You can manage the change tracking state of individual properties as follows:
Hello,
As far as CLR types are not tracked by ef core (#1117)
What's the proper way of updating inner entities?
models.cs
context.cs
test.cs
Saving works without any issues. But once I try to edit data, I`m setting Modified state manually.
And that action causes exception: System.InvalidOperationException: The entity type 'CouponConfiguration' was not found. Ensure that the entity type has been added to the model.
It`s possible to bypass that exception when setting the whole entity to state modified, then update works.
But doing that will cause ef core to update ALL properties, instead of only one inner object.
Is it possible to bypass that limitation\exception somehow?
Thanks,
Stas
The text was updated successfully, but these errors were encountered: