https://github.com/sample-by-jsakamoto/efcore.nonnullableownedentity.sampleapp
https://github.com/sample-by-jsakamoto/efcore.nonnullableownedentity.sampleapp
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sample-by-jsakamoto/efcore.nonnullableownedentity.sampleapp
- Owner: sample-by-jsakamoto
- License: unlicense
- Created: 2019-11-19T12:50:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-19T13:16:17.000Z (over 5 years ago)
- Last Synced: 2025-04-09T23:55:32.436Z (2 months ago)
- Language: C#
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sample App - EntityFramework Core - Non-Nullable Owned Entity
## Summary
This sample source code is to reproduce my problem.
See also:
- [aspnet/EntityFrameworkCore - Issue #16943 - "[Required]/IsRequired() on properties of owned entities is ignored"](https://github.com/aspnet/EntityFrameworkCore/issues/16943)
- [aspnet/EntityFrameworkCore - Issue #12100 - "Enable configuring required 1-to-1 dependents"](https://github.com/aspnet/EntityFrameworkCore/issues/12100)**Please vote 👍 [#12100]((https://github.com/aspnet/EntityFrameworkCore/issues/12100))!**
## What's the problem?
My `DbContext` class has the "People" DbSet like this.
```csharp
public class Person
{
public int Id { get; set; }
...
public Metric Metric { get; set; }
}
```The `Metric` class is owned entity, like this.
```csharp
[Owned]
public class Metric
{
public double Height { get; set; }public double Weight { get; set; }
}
```When I generate the database from these model on EFCore v.2.x, the `Metric_Height` and `Metric_Weight` columns on the table are non-nullable type, expectedly.
However, when I do the same task on EFCore v.3.x, those columns **are not non-nullable** type.

## License
[The Unlicense](LICENSE)