Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow Property - ChangeTracker Modified State #4474

Closed
CharlesToniolo opened this issue Feb 3, 2016 · 0 comments
Closed

Shadow Property - ChangeTracker Modified State #4474

CharlesToniolo opened this issue Feb 3, 2016 · 0 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@CharlesToniolo
Copy link

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

@rowanmiller rowanmiller added this to the 1.0.0-rc2 milestone Feb 5, 2016
ajcvickers added a commit that referenced this issue Mar 28, 2016
Shadow properties get this state when entities are first attached. These properties are then not considered modified even if the entire entity is marked as modified and so the values for these properties are not saved. The properties are only considered as modified or not when an actual value is set.

See #4474
ajcvickers added a commit that referenced this issue Mar 29, 2016
Shadow properties get this state when entities are first attached. These properties are then not considered modified even if the entire entity is marked as modified and so the values for these properties are not saved. The properties are only considered as modified or not when an actual value is set.

See #4474
@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Oct 15, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

3 participants