and Currently I am getting this error message in catch block
Data is Null. This method or property cannot be called on Null values.
The error usually means there null values in the SQL table but the model design does not have an associated nullable type. Please see the reference documentation.
I want to use Either FromSqlInterpolated or FromSqlRaw . Can we fix it ?
I showed you how to handle a nullable SQL input parameter above. Your second code sample does use a null input parameter so I'm not sure what problem you are having. Perhaps reread the docs to learn how to create a parameter in C#.
https://learn.microsoft.com/en-us/ef/core/querying/raw-sql#passing-parameters