❔ data is null. method or property cannot be called on null value
Everything but the ID is nullable on both the database and the model
I've not set fluent api or the model up with all of the database tables values but it can't be the issue, can it?
All I'm currently trying to do is just get a list of my object
11 Replies
Apparently one row had a value that was null
I don't currently use this value in EF so why is it causing an error?
Idk? I can't really give you anything with 0 context on what your code/database looks like
I can't have discord on my work laptop or really share the code
But it's currently complaining about a string/varchar being null
Oh boy I know that problem
Discord is not work-related enough
I had that discussion before
As far as I'm aware EF does not allow anything that is null into a column when you set the rule that it's required
You can check your latest snapshot to check if everything has
IsRequired()
set?Sorry for the late reply
I have tried having it removed and .is required(false)
Both are not working
You want it to not allow null though, right?
IsRequired basically prevents null values
But your code should be set up so it's not nullable either
No I want to allow null
All I'm doing is a simple dumb select
I don't care about that value if it's null or not
Is it something new in .net 6?
I've never had this issue in the old .net core 3 projects i was on before
If a property is
string
then it's not-nullable
If you want to make it nullable... make it nullable
string?
And, yes, non-nullable reference types are a .NET 6 thingI've tried that as well and that doesn't work either
So far it's not a feature that I like
Right my property is string?
I have tried to set IsRequired(false) in fluent api and I have tried not having it
I have even tried setting Nullable to disabled in the project
The only thing that works is selecting everything else and excluding the column that's has null values
For fucks sake
The issue was that the property was being used in a composite key
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.