.I created project with .net core 6.
GroupImageName is nullable but when I do migration, this property is created non-nullabe,also for example, posts property is created non-nullable.
-
1Please upload code in text instead in images. Images can't be searched and therefore aren't useful to future readers, harder to read than text.Victor– Victor2022-09-14 10:28:07 +00:00Commented Sep 14, 2022 at 10:28
Add a comment
|
1 Answer
To make a nullable properties from code first you have to use Nullable<string> or string? which makes your property nullable in database after migration
E.g. in your case your model looks like below:
PostGroup.CS
Public class PostGroup
{
public int GroupId{get;set;}
public string GroupName {get;set;}
public string? GroupImageName {get;set;}
.
.
.
n so on properties
}
after making above change just run the command like below from PMC
add-migration
update-database
above stapes will make your properties nullable in db after successful migration