Page 1 of 1

XMLType in Entity Framework 6

Posted: Thu 21 Dec 2017 09:39
by Roeland
Hi,

I have in the database a column of type XMLType.

In a code first scenario, how should I map the XMLType in my model?

I tried mapping it to string.

Reading the entity: no problems
Writing the entity:
- No problem if I put a MaxLength of 4000, but then I can't write an XML > 4000
- If I do not put a MexLength on it, I get the following error:
ORA-00932: inconsistent datatypes: expected - got CLOB

How should I do this with EF?

Re: XMLType in Entity Framework 6

Posted: Thu 21 Dec 2017 11:40
by Shalex
Please try this setting: config.CodeFirstOptions.UseNonLobStrings=true;

Refer to http://devart.com/dotconnect/oracle/doc ... tions.html.

Does this help?

Re: XMLType in Entity Framework 6

Posted: Thu 21 Dec 2017 13:26
by Roeland
I already tried that one and that limits the size to 2000 characters.
Also I tried the recommended way for EF6 (https://blog.devart.com/entity-framewor ... force.html):

Code: Select all

modelBuilder
      .Properties()
      .Where(p => p.PropertyType == typeof(string) && 
                  p.GetCustomAttributes(typeof(MaxLengthAttribute), false).Length == 0)
      .Configure(p => p.HasMaxLength(2000));
But obviously the same problem with xml > 2000 characters

Re: XMLType in Entity Framework 6

Posted: Sat 23 Dec 2017 07:13
by Shalex
Please set column type in fluent (or attribute) mapping explicitly: .HasColumnType("xmltype");

Notify us about the result.

Re: XMLType in Entity Framework 6

Posted: Wed 27 Dec 2017 16:26
by Roeland
Yes! That works!

Thanks!