Update:
All I said previously still applies, with just additional ways of getting the things wrong due to the later EF Core nullability rules changes (most noticeable are the string properties inside NRT enabled projects which now are considered required by default, which is totally opposite of what they are considered in non NRT enable context).
What I would like to add here is the mechanism of detecting which column/property is causing the issue.
I kind of lose track of which exact EF Core version added such functionality, but in recent EF Core versions, you can use the EnableDetailedErrors method to turn detail error logging on, and then instead of the OP exception (it’s still there, but as an inner of the new) you’ll get InvalidOperationException with message similar to this
An error occurred while reading a database value for property ‘{EntityName}.{PropertyName}’. The expected type was ‘System.String’ but the actual value was null.
where {EntityName}.{PropertyName} is the offending property.
Original:
The error message indicates that EF Core is trying to read string value for a required property, i.e. a property which should never have null value in the database, but instead the underlying data reader reports null value for that property in some record(s).
Looking at your entity model and corresponding database table, you can see the obvious discrepancy for many string properties -> varchar columns. CompanyStreetAddress, CompanyCity, CompanyZipCode, CompanyVatNumber, ContactFirstName, ContactLastName – all these are marked as [Required] in the model, but have no corresponding not null constraint in the table.
So the problem is caused by one or more of these columns.
You need to fix that discrepancy – probably by removing [Required] attribute because the constraint is already broken in the existing data.
The fact that it “works” in some older EF Core version doesn’t matter – that’s incorrect mapping and as such should be fixed. Technically it shouldn’t work from the beginning. But remember that EF Core is still in active development and has many bugs which are fixed in the next release(s). Most likely some code change was made between “working” and “non working” EF Core version which fixes the previous incorrect behavior.