I am having this issue after migrating my project from .NET 5 to .NET 6. I am using the latest version of SQLite as the database.
It seems to be assuming that string is no longer nullable by default instead of nullable. Whenever Entity Framework tries to write to a field that is not a primary or foreign key I get the error SQLite Error 19: 'NOT NULL constraint failed. In .NET 5 I was not getting this error.
I also noticed that VS 2022 Intellisense has a green indicator line under each of the property names that cause this error. It states Non-nullable property must contain a non null-value when exiting constructor. Consider declaring the property as nullable.
When I add the nullable operator, ?, to the property types causing the error, the green indicator line and the SQLite Error 19: 'NOT NULL constraint failed' go away.
Example of code the causes the error:
[Table("ApplicationUser")]
public class ApplicaitonUser : IdentityUser
{
// Inherited properties https://docs.microsoft.com/en-us/aspnet/core/security/authentication/customize-identity-model?view=aspnetcore-6.0
[Key]
public new int Id { get; set; } // every other property causes the SQLite 19 error
[PersonalData]
public string FirstName { get; set; }
[PersonalData]
public string MiddleName { get; set; }
[PersonalData]
public string LastName { get; set; }
[PersonalData]
public string PreferredName { get; set; }
// Address Table Foreign Key relationship navigation property
[PersonalData]
ICollection<UsAddress> UsAddresses { get; set; }
}