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.

Support modifying the value of primary or alternate key properties

See original GitHub issue

In the following location, an exception is raised when attempting to make modifications to a property that belongs to either a primary or alternate key (using the IsKey extension method):

https://github.com/aspnet/EntityFramework/blob/7.0.0-rc1/src/EntityFramework.Core/ChangeTracking/Internal/InternalEntityEntry.cs#L231

I have to ask: why restrict modifications on alternate keys, and why not use IsPrimaryKey here instead?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:19
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
AndriySvyrydcommented, Oct 22, 2019

@SidShetye Configuring it as a unique index in EF would be the most accurate approximation. If you don’t use EF to manage the schema you don’t even need to add the index, EF doesn’t use it.

If you do use migrations you can change the generated code to create a key instead.

1reaction
SidShetyecommented, Oct 22, 2019

@AndriySvyryd Like I mentioned, we share that database (don’t control the schema; not using migrations etc). We’re just trying to regenerate it’s closest approximation in the C# EF Core 3.0 model. Not having that limitation would allow for a more accurate approximation of the actual SQL database in EF Core.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modifying an alternate key in a "disconnected" scenario ...
I had an alternate key on the Title field because I intended for it to be unique. ... the alternate key is back...
Read more >
Keys - EF Core
By convention, an alternate key is introduced for you when you identify a property which isn't the primary key as the target of...
Read more >
Work with alternate keys (Microsoft Dataverse) - Power Apps
This alternate key can be used to uniquely identify a row in Dataverse in place of the primary key. You must be able...
Read more >
c# - The property is part of a key and so cannot be modified ...
To change the principal of an existing entity with an identifying foreign key, first delete the dependent and invoke 'SaveChanges', and then ...
Read more >
c# - What's the real difference between Alternate Key and ...
The issue of mutable alternate keys is being tracked at Support modifying the value of alternate key properties, so please upvote to elevate ......
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