Aquaphobix
DDD Dotnet-ef 8 error/bug? Making migrations breaks build in dotnet 8
I've been stuck on a dotnet-ef related bug/error for a few hours and I'm out of ideas.
I'm working through Amichai Mantinband's Domain Driven Design Rest API course on youtube, and been trying to validate if what I'm learning translates in to dotnet 8.
All has been going well until today, where my dotnet 8 version breaks when I make the dotnet ef migrations.
I've made a repo here to demo: https://github.com/Aidenwebb/bd-dotnet7-vs-dotnet8
In the repo, there are two folders. "BuberDinner-original" which is targetting dotnet 7, and "BuberDinner-dotnet8" which is identical with the exception that the sln/csproj/Directory.Build.Props now target dotnet 8, and packages are updated.
Primarily, the issue seems to be that in dotnet-ef 8, running the migrations adds .HasDiscriminator on line 417 and 659 of ./bd-dotnet7-vs-dotnet8/BuberDinner-dotnet8/BuberDinner.Infrastructure/Migrations/20231230190557_InitialCreate.Designer.cs
The next time the application tries to build, it fails with error: /workspaces/bd-dotnet7-vs-dotnet8/BuberDinner-dotnet8/BuberDinner.Infrastructure/Migrations/BuberDinnerDbContextModelSnapshot.cs(414,32): error CS1061: 'OwnedNavigationBuilder' does not contain a definition for 'HasDiscriminator' and no accessible extension method 'HasDiscriminator' accepting a first argument of type 'OwnedNavigationBuilder' could be found (are you missing a using directive or an assembly reference?) [/workspaces/bd-dotnet7-vs-dotnet8/BuberDinner-dotnet8/BuberDinner.Infrastructure/BuberDinner.Infrastructure.csproj]
I've created a devcontainer in each, and a makefile to help in running the test sequence.
If you have docker and fire up the dev container, running make demo will run through the sequence to trigger the issue in the dotnet-8 folder, or run through successfully in the original folder
Any ideas and guidance would be wonderful.
1 replies