-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Milestone
Description
Hello,
I'm having a strange behavior with a shadow property and i don't know if it's a bug or not.
I was able to reproduce it in the dev branch.
Given these classes:
namespace Microsoft.EntityFrameworkCore.FunctionalTests.TestModels.Northwind
{
public class ExtraValue
{
public string ID { get; set; }
public string Description { get; set; }
}
}
namespace Microsoft.EntityFrameworkCore.FunctionalTests.TestModels.Northwind
{
public class Order
{
//public string ExtraValueID { get; set; } Shadow Property
public ExtraValue ExtraValue { get; set; }
public int OrderID { get; set; }
public string CustomerID { get; set; }
public int? EmployeeID { get; set; }
......
}
}
I would like to have a Shadow Property called ExtraValueID to be the foreign key to the table ExtraValue.
Entity framework is automatically creating this Shadow Property but when i select the root entity with AsNoTracking and Update the entity without changing anything like this:
var order = context.Orders.AsNoTracking()
.Include(o => o.ExtraValue)
.Where(o => o.OrderID.Equals(10248))
.FirstOrDefault();
context.Update(order);
The Shadow Property context.Entry(order).Property("ExtraValueID") is being marked as modified with originalValue=null.
I think that this property should not be marked as modified. If i create the property ExtraValueID inside the class Order, it works.
Thanks