edandersen / core-admin

Fully automatic admin site CRUD UI generator for ASP.NET Core and .NET 8
Other
561 stars 106 forks source link

System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values. #83

Closed Dredy closed 1 year ago

Dredy commented 1 year ago

Trying to view a table with many NULL fields (Allow nulls checked in table designer) i receive the following error

System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values. at Microsoft.Data.SqlClient.SqlBuffer.ThrowIfNull() at Microsoft.Data.SqlClient.SqlBuffer.get_String() at Microsoft.Data.SqlClient.SqlDataReader.GetString(Int32 i) at lambda_method84(Closure , QueryContext , DbDataReader , ResultContext , SingleQueryResultCoordinator ) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext() at System.Linq.Enumerable.SelectIterator[TSource,TResult](IEnumerable1 source, Func`3 selector)+MoveNext() at AspNetCoreGeneratedDocument.Views_Shared_MvcGrid__Grid.ExecuteAsync()

it seems that MvcGrid tries to get a value from a null field.

There is any suggestino to avoid this problem?

Thank You.

Dredy commented 1 year ago

I solved the issue by myself.

nullable disable

on top of the model class