Entity Framework 4.1 Code First and Oracle CLOB

I currently have my first code model:

public class Ticket
{
    public int SERIAL_NO { get; set; }
    public DateTime SUBMIT_DATE { get; set; }
    public string SYNOPSIS { get; set; }
    public string DESCRIPTION { get; set; } // This is really an Oracle CLOB in the DB
}

      

In the ticket controller, when the user clicks the submit button, I have a selection from SERIAL_NO from the database, like this:

var lastSerial = db.Tickets.Select(x => x.SERIAL_NO).Max();

      

It throws this error:

ORA-00932: inconsistent datatypes: expected - got NCLOB

      

Does anyone have any idea? Thanks in advance!

+3


source to share


4 answers


The newest ODP.NET release (at the time of this writing) is 11.2.0.3

Unfortunately this version does not support Code First yet (see Oracleยฎ Data Provider for .NET Developer Guide for reference)

Entity Framework 4.1 is supported. However, Code First, which is part of Entity Framework 4.1, is currently not supported.



If you're willing to pay, DevArt claims their vendor supports Code-First . They offer a free trial for you to check out.

Another option is to generate code using EDM Designer.

+1


source


The original problem (getting error ORA-00932) in the query is that you cannot use DISTINCT when the SELECT list contains a field with a large (such as CLOB) data type. Does your generated SQL contain a DISTINCT clause and return a DESCRIPTION field?

It shows that a CLOB can potentially hold GB of data by returning only individual columns, which could mean comparing the GB in each individual column to GB or all other columns in the result set.



I am guessing that other aggregate functions will also fail (min, max), as well as using a CLOB column is fine, for the same reason. Since this is an old question, and the tip I have given tends to solve the head-scratching problem for most coders, I will not search for relevant places in the SQL reference. Those looking for more details now know where to look (or what to look for).

+1


source


On you Model add the attribute [StringLength (100)]

0


source


In stake mapping

.HasColumnType("CLOB")

      

0


source







All Articles