question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alternate foreign keys incorrectly updated on navigation property entities

See original GitHub issue

In breeze.debug.js, on line 5405 in setNpValue, the statement: var inverseKeyProps = property.entityType.keyProperties; incorrectly assigns the inverse property’s key properties and the result is that the primary key values of the inverse navigation property are assigned to the foreign key properties instead of their original values and data is corrupted. Consider the following scenario: A Department object has an Id primary key, a DeptId alternate foreign key that is unique, and a navigation property of DepartmentMembers, an array of class DepartmentMember that has an Id (primary key), DeptId related to Department.DeptId, and a MemberId. In this scenario instead of the original value of DeptId being used upon loading into the navigation property, setNpValue will assign the Department.Id value to DepartmentMember.DeptId instead of correctly maintaining the inverse foreign key mapping of Department.DeptId to DeparmentMember.DeptId, resulting in corrupted data. updating the statement on line 5405 as follows fixes this issue: var inverseKeyProps = property.entityType.inverseForeignKeyProperties;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
steveschmittcommented, Apr 29, 2021

I was able to reproduce the problem in tests, and have fixed in breeze-client 2.1.1. Now Breeze supports relationships to foreign keys that are not the PK.

1reaction
EchoFoxxtrotcommented, Feb 26, 2018

Correct. the isScalar property is false because it is a list/array for a one-to-many relationship. I did get everything working for navigation properties both one-to-many and one-to-one, but I did have to modify Breeze to do it. I’m pressed for time on a project, but once I have it completed, I will be making a pull request with the modifications.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing Foreign Keys and Navigations - EF Core
How to change relationships between entities by manipulating foreign keys and navigations.
Read more >
EF Core updating foreign key is not updating the navigation ...
When you're doing the mapping, you could update the navigational property with the actual values of the new relationship. So map User.
Read more >
Alternate foreign keys incorrectly updated on navigation property ...
Consider the following scenario: A Department object has an Id primary key, a DeptId alternate foreign key that is unique, and a navigation...
Read more >
Entity Framework Core: Foreign key linked with a non-primary ...
Configure a principal key or a set of compatible foreign key properties for this relationship. This error occurs because you are trying to...
Read more >
MySQL FOREIGN KEY constraint is incorrectly formed
Both the referencing and referenced columns must be of the same type (and same in this case includes the unsigned attribute).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found