This program creates the following EF model:
Blog
| 1..1
Post
/|\ 1..m
Image
Then performs the following operations:
- Create a new Blog with a Post titled "A"
- Fetch the Blog, replace its Post with a new entity titled "B", and then add an Image to the Post
- Fetch the Post and display its title
The fetched Post title should be "B" but is "A".
-
Create the database:
dotnet tool install --global dotnet-ef dotnet ef migrations add InitialCreate dotnet ef database update -
Run the app:
dotnet runAnd it incorrectly outputs:
Blog post title = A -
Uncomment the line:
// var _ = blog.Post; -
Re-run the app and it correctly outputs:
Blog post title = B