Search code examples
c#enumsentity-framework-pluseffort

EffortException when trying to BulkInsert a class with a nullable enum


I'm trying to write some tests that assert my repository implementation is correct. I'm using Entity-Framework-Extensions library's BulkInsert method. The class I'm inserting has a nullable enum as a property. When I execute my test I get an EffortException that stems from a System.InvalidCastException. The message seems to indicate that the enum string value is being used not its corresponding int value. Is there some sort of annotation / config I can provide to get it to properly convert the enum.

Effort.Exceptions.EffortException An unhandled exception occurred while trying to assign value 'StateTransition' to Property 'MandatoryJobCommentType' of type 'System.Nullable`1[System.Int32]' during entity initialization for table 'Effort.Internal.DbManagement.Schema.TableName' at Effort.Internal.DbManagement.Schema.DbTableInfo.HandleConvertException(Exception exception, PropertyInfo property, Object value)


Solution

  • The issue was inside the Entity Framework Extensions library when a nullable enum was used with a bulk operations (only for Effort).

    The issue has been fixed in the v7.100.0.0

    Disclaimer: I'm the owner of the project Entity Framework Effort and Entity Framework Extensions