Migration not reflecting Model correctly
Context: I'm using .NET core 6.0, ASP.NET MVC, trying to initiate the db with Migrations
Got this error:
I clearly defined the ParentId to be nullable here:
Any suggestion on how I can fix this? I think I can just modify the generated migration file, but I'm afraid that would break the migrations.
4 Replies
Tried [AllowNull] on the ParentId field. Didnt work
It's telling you that the id must not be nullable
Yeah, but I want it to be nullable, it's just a foreign key
Found out that it's a default setting in .csproj
Stack Overflow
String is not nullable by default in Entity Framework Core 6.0
I was creating a database table in Entity Framework Core 6.0. I was using code first approach in my project.
There was a string type property in TestModel named Address.
using System.ComponentModel.