-
Notifications
You must be signed in to change notification settings - Fork 3.3k
EF core 6 returns null value for owned entity #27516
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
How was the column created? EF Core Migrations, or some other way? |
Hi @ajcvickers, not sure I understand the question. This is code-first. I added the NotUsed boolean property to several owned entity classes in my data model, then I ran add-migration to create new migration. The scaffolded migration code adds a new nullable column for every parent entity's reference to one of the owned entities. When I I'm being lazy... I haven't spent the time to try to create a simple repo of the problem. I'm crossing my fingers and hoping that someone at your end will look at it and say "oh, yea, that's a reproduceable bug". |
@sbsw Thanks; I will discuss with the team. |
And, if it helps... here's the actual (full) code for the owned entity:
And the interface:
And the fluent configuration
|
Duplicate of #25359. See also dotnet/EntityFramework.Docs#3750. |
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work] [regression] [worked-in:>Net Core 5, EF Core 5]
I recently upgraded my project to .Net Core 6, EF Core 6. I started getting this error message when I create a new migration or when I update-database:
Ok,
PersonalName
is an owned entity consisting entirely of string properties. So I added a new property to the owned entity class:That made the validation error go away, but now the property that should hold the owned entity is null, even though the SQL database has non-null values for many of the owned entity columns.
I have noticed a couple of (possibly) interesting things about this problem:
public bool NotUsed { get; set; }
property then the query correctly returns the non-null owned entity.NotUsed
Boolean column is nullable, despite the fact that it is a non-nullable data type and the parent entity does not inherit from a base entity class. Adding a[Required]
attribute in the data model or fluent configuration in the DbContext has no effect on this.Original Comments
Feedback Bot on 2/25/2022, 06:34 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: