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

When the .NET Entity Framework retrieves data from the database and parses it into the structure that we specify in our code, we have to make sure nullable columns are modeled with nullable properties in our code.

When null values are retrieved and the structure in the code does not allow null value in any property, we get the System.Data.SqlTypes.SqlNullValueException exception

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

Make sure all nullable columns are modeled with nullable properties.

CREATE TABLE [dbo].[task](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[filenames] [nvarchar](max) NULL,
	[source_path] [nvarchar](255) NULL,
	[target_path] [nvarchar](255) NULL


    public class task
    {
        public int id { get; set; }
        public string? filenames { get; set; }
        public string? source_path { get; set; }
        public string? target_path { get; set; }
    }

Leave a comment

Your email address will not be published. Required fields are marked *