OData / OData/AspNetCoreOData

Using NotMapped annotation on Id Property throws UnhandledException

Open
#93 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

I'm trying to implement some logic which will redact from the OData response a value which has been marked as a primary key. When the application then spins up I get an error similar to the following:

The entity set 'Foo' is based on type 'Default.Foo' that has no keys defined.

I get that the framework is trying to enforce well-defined keys here, but this sadly doesn't fit my use case. Are there any known workaround to this other than creating a custom ODataEntitySerializer?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by reproducing startup with a NotMapped annotation on an Id property and trace the entity-set key validation; compare that behavior with the custom ODataEntitySerializer mentioned in the report. Done means identifying and documenting a supported workaround for redacting the primary-key value without leaving the entity set keyless.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.