dotnet / dotnet/EntityFramework.Docs
One-to-one without navigation to principal and with shadow foreign key :: examples are equals
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
In paragraph [One-to-one without navigation to principal and with shadow foreign key](https://learn.microsoft.com/en-us/ef/core/modeling/relationships/one-to-one#one-to-one-without-navigation-to-principal-and-with-shadow-foreign-key) the two examples are the same, both snipped code are :
```
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity()
.HasOne(e => e.Header)
.WithOne()
.HasForeignKey("BlogId")
.IsRequired();
}
```
Perhaps the second could be :
```
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity()
.HasOne(e => e.Header)
.WithOne()
.HasForeignKey("BlogId")
.IsRequired(false); // <----------------------------------- false
}
```
Best regards
---
#### Document Details
⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*
* ID: 8eb0a65d-4cc1-5f0a-2ffa-2875e9f9d586
* Version Independent ID: 8eb0a65d-4cc1-5f0a-2ffa-2875e9f9d586
* Content: [One-to-one relationships - EF Core](https://learn.microsoft.com/en-us/ef/core/modeling/relationships/one-to-one#one-to-one-without-navigation-to-principal-and-with-shadow-foreign-key)
* Content Source: [entity-framework/core/modeling/relationships/one-to-one.md](https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/modeling/relationships/one-to-one.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @ajcvickers
* Microsoft Alias: **avickers**
Contributor guide
Assessment
This issue has not been assessed yet.