Our project recently updated to the newer Oracle.ManagedDataAccess DLL's (v 188.8.131.52) and this error has been cropping up intermittently. We've fixed it a few times without really knowing what we did to fix it.
I'm fairly certain it's caused by CLOB fields being mapped to strings in Entity Framework, and then being selected in LINQ statements that pull entire entities instead of just a limited set of properties.
Value cannot be null. Parameter name: byteArray
at System.BitConverter.ToString(Byte value, Int32 startIndex, Int32 length) at OracleInternal.TTC.TTCLob.GetLobIdString(Byte lobLocator) at OracleInternal.ServiceObjects.OracleDataReaderImpl.CollectTempLOBsToBeFreed(Int32 rowNumber) at Oracle.ManagedDataAccess.Client.OracleDataReader.ProcessAnyTempLOBs(Int32 rowNumber) at Oracle.ManagedDataAccess.Client.OracleDataReader.Read() at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.StoreRead()
Suspect Entity Properties:
'Mapped to Oracle CLOB Column' <Column("LARGEFIELD")> Public Property LargeField As String
But I'm confident this is the proper way to map the fields per Oracle's matrix:
There is nothing obviously wrong with the generated SQL statement either:
SELECT ... "Extent1"."LARGEFIELD" AS "LARGEFIELD", ... FROM ... "Extent1" WHERE ...
I have also tried this Fluent code per Ozkan's suggestion, but it does not seem to affect my case.
modelBuilder.Entity(Of [CLASS])().Property( Function(x) x.LargeField ).IsOptional()
After extensive testing, we are quite certain this is actually a bug, not a configuration problem. It appears to be the contents of the CLOB that cause the problem under a very specific set of circumstances. I've cross-posted this on the Oracle Forums, hoping for more information.
After installation of Oracle12 client we ran into the same problem. In machine.config (C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config) I removed all entries with Oracle.ManagedDataAccess. In directory C:\Windows\Microsoft.NET\assembly\GAC_MSIL I removed both Oracle.ManagedDataAccess and Policy.4.121.Oracle.ManagedDataAccess. Then my C# program started working as usually, using the Oracle.ManagedDataAccess dll in it's own directory.