EF + ODP.NET + CLOB = Value Cannot be Null - Parameter name: byteArray?

entity-framework entity-framework-6 odp.net odp.net-managed oracle


Our project recently updated to the newer Oracle.ManagedDataAccess DLL's (v 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

Stack Trace:

   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'
Public Property LargeField As String

But I'm confident this is the proper way to map the fields per Oracle's matrix:

ODP.NET Types Overview

There is nothing obviously wrong with the generated SQL statement either:

FROM ... "Extent1"

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

Troubleshooting Update:

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.

2/25/2015 7:41:42 PM

Popular Answer

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.

12/28/2016 2:05:23 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow