What is the better way to identify who is the exact culprit in this exception?
Root Cause: Database Column and Entity Property mismatch (Nullable in Db and NotNULL in C# Entity).
Message: Data is Null. This method or property cannot be called on Null values.
StackTrace:
I want to know Can we figure out which is the exact column for which type or nullability has not matched?
6 Replies
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
I can go down and debug it, But I wanted to know, is there a better way to either identify or avoid such blunders. I can create an utility that can do some checking between my database tables and entities in the C# or I have another solution as well where I can create a code generator that can generate entities using database tables.
There can be plenty of options, I wanted to open up this conversation to understand what is the right way.
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
GitHub
GitHub - Giorgi/EntityFramework.Exceptions: Strongly typed exceptio...
Strongly typed exceptions for Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql. - Giorgi/EntityFramework.Exceptions
i don't know if it will give you the exact info you want for null entries into columns, etc., but this package is probably of interest to you
you could also switch on more detailed logging from ef core to see what sql it tried to execute before the exception
i don't know if there's a good way to catch these kinds of errors at compile-type in c#. there is some promising stuff in rust (like diesel), but i think that is mainly possible because of rust's more advanced type system and macro capabilities
i sure wish there was a good way to do this, it would have saved me a lot of time and broken builds 🙂
Thank you I will look into it..