InvalidCastException on wrong property type in entity
exception message when mapping is not compatible is not very detailed and don't even say what property was problematic one
---> System.AggregateException: One or more errors occurred. (Unable to cast object of type 'System.Byte' to type 'System.String'.)
---> System.InvalidCastException: Unable to cast object of type 'System.Byte' to type 'System.String'.
@kamkie please post the full exception including the stack trace, as well as a minimal code sample which triggers this exception; there's not much we can do with an isolated exception message.
it is not about bug that you need to reproduce and fix
it is about error message
you have column in database that is tinyint -> it should be byte in entity but I did mistake and put string there
but I have 20 or 100 columns in that table/entity and I don't know which one is wrong
@kamkie See https://learn.microsoft.com/en-us/ef/core/logging-events-diagnostics/extensions-logging?tabs=v3#detailed-query-exceptions. If that doesn't help, then please post more information as requested by @roji.
optionsBuilder.EnableDetailedErrors(); solves my problem