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

Allow to specify FieldInfo for a shadow property in Fluent API #15307

Closed
AndriySvyryd opened this issue Apr 10, 2019 · 5 comments · Fixed by #17976
Closed

Allow to specify FieldInfo for a shadow property in Fluent API #15307

AndriySvyryd opened this issue Apr 10, 2019 · 5 comments · Fixed by #17976
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 regression type-bug
Milestone

Comments

@AndriySvyryd
Copy link
Member

No description provided.

@ajcvickers
Copy link
Member

We think this might mean that when a property is configured as a shadow property, it can later get a FieldInfo and become a field-backed non-shadow property.

@divega
Copy link
Contributor

divega commented Sep 15, 2019

We made the decision that during EF Core 3.0 we would re-enable configuration like this, after breaking it in preview 4. From the breaking change documentation:

Mitigations

Field-only properties must be named the same as the field they are mapped to. In a later preview of EF Core 3.0, we plan to re-enable explicitly configuring a field name that is different from the property name:

modelBuilder
   .Entity<Blog>()
   .Property("Id")
   .HasField("_id");

Unfortunately we ended up punting this past 3.0.

@smitpatel smitpatel added this to the 3.1.0 milestone Sep 20, 2019
AndriySvyryd added a commit that referenced this issue Sep 21, 2019
Don't throw from BackingFieldConvention until the model is finalized.

Fixes #15307
Fixes #17691
@AndriySvyryd AndriySvyryd removed their assignment Sep 21, 2019
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 21, 2019
@ajcvickers ajcvickers modified the milestones: 3.1.0, 3.1.0-preview1 Oct 15, 2019
@ajcvickers ajcvickers modified the milestones: 3.1.0-preview1, 3.1.0 Dec 2, 2019
@hisuwh
Copy link

hisuwh commented Jun 29, 2021

This issue is closed but this does not seem to be fixed. Is this a valid workaround?:

modelBuilder
   .Entity<Blog>()
   .Property("_id")
   .HasColumnName("Id");

@AndriySvyryd
Copy link
Member Author

@hisuwh The issue was fixed in 3.1.11, if you are still experiencing it in 5.0.0 or later please open a new issue.

The proposed workaround is correct.

@hisuwh
Copy link

hisuwh commented Jun 30, 2021

I'm using 3.1.16 and am still experiencing this issue. I'm not in a position to move to 5.0.0 yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 regression type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants