We use the EF code first with EF 6.1.3 and SimpleInjector 3.1.0, and we accidentally get exceptions similar to this:
The "IsDeleted" property in "Location" cannot be set to "System.Int32". You must set this property to a non-zero value of type "System.Boolean".
in System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue (DbDataReader reader, Int32 ordinal)
in System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetPropertyValperWithrror ] (Int32 ordinal, String propertyName, String typeName)
on lambda_method (Closing, Shaper)
in System.Data.Entity.Core.Common.Internal.Materialization.Coordinator`1.ReadNextElement (shader shaper)
in System.Data.Entity.Core .Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext ()
in System.Linq.Enumerable.FirstOrDefault [TSource] (IEnumerable`1 source)
In this case, the “Location IsEeleted” bit / column is not zero. And the Property property on the location object is definitely not NULL. I checked the entire history of the object in our git repository, and this property has never been anything other than a logical one, and the current dll on the server is correct, so I don’t like that the problem is caused by the wrong code / DLL.
What is really strange is that most of the time our site works fine, I would expect this exception to happen every time. What is weirder is that we saw the same type error on three other objects (also, it would seem, randomly). In each case, it was a different property and data type. For example:
"" "SysGroup" "System.Boolean". "System.Int32".
"SysGroupId" "SysInfo" "System.String". "System.Int32".
"Id" "BaseEntity" "System.Guid". "System.Int32".
... , BaseEntity, null-nullable "Id". Guid. , BaseEntity Guid Id, . , , :
var desc = SysInfoInstance.SysGroup.Description;
?
Location :
public class Location :
BaseEntity
{
...
public virtual bool IsDeleted { get; set; }
}
public abstract class BaseEntity
{
public virtual int Id { get; set; }
}