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

Error when updating the entity with primary key default value (zero). #23737

Closed
ethembynkr opened this issue Dec 19, 2020 · 1 comment
Closed

Comments

@ethembynkr
Copy link

ethembynkr commented Dec 19, 2020

I get error when updating the entity with primary key 0(zero). How can I fix it?

public class User
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int Id { get; set; }
        public LocalizedEntity NationalityName { get; set; }
    }
[Owned]
public class LocalizedEntity
    {
        public string Primary { get; set; }
        public string Secondary { get; set; }
    }

Error:

InvalidOperationException: The value of 'User.NationalityName#LocalizedEntity.UserId' is unknown when attempting to save changes. This is because the property is also part of a foreign key for which the principal entity in the relationship is not known.

EF Core version: 5.0.0

@smitpatel
Copy link
Contributor

Duplicate of #23730

@smitpatel smitpatel marked this as a duplicate of #23730 Dec 21, 2020
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants