SqlNullValueException: Data is Null. This method or property cannot be called on Null values.

When you have fields in a table that may contain null values, it's better to clarify this in your .NET Core model.

For example, you can denote nullable fields using the ? character, like so:

public int? RefID { get; set; }        

However, when I ran my program, it showed an error due to many fields being null. I resolved this issue by adding the following lines to the <PropertyGroup> in the project file:

<PropertyGroup>
    <Nullable>warnings</Nullable>
</PropertyGroup>        

This modification configures how the compiler handles nullability, helping to prevent errors related to null handling in .NET Core projects.

سلام لیلاجان خوبی؟ فاطمه احمدی هستم. گوشیم ریست شده چند وقته ازت خبر ندارم.

Like
Reply

To view or add a comment, sign in

More articles by Leyla Isazadeh

  • absolute path

    when you want to use absoluthe path in your asp.net core vs react: 1- add a jsconfig.

  • برنامه نویسی

    شروع کدنویسم از سی شارپ بود.البته اگه از پایان نامه ها بگذریم.

    2 Comments

Explore content categories