• 2 replies
  • Latest Post - ‏2013-10-14T09:25:00Z by Anateus
1 Post

Pinned topic .NET 4.0 EF5 TPT inheritance with DB2 10.1 and 10.1 data provider

‏2013-06-27T21:32:39Z | . entity framework

{"ERROR [42704] [IBM][DB2] SQL0204N  \"BOOLEAN\" is an undefined name."}

Assume I have a Person table for a PersonType and I have other types that derive from the PersonType like Employee or Contractor. Well there may be the case where the Person is neither of those and so I'd want just the persons information. I've tested the code implementing this idea in SQL Express and it works fine but with DB2 on 10.1 provider and EF5 I receive the above error. Anyone have experience with inheritance issues out of EF and DB2?


public class Person {
    // Some properties tied to person table.

public class Employee : Person {
    // Some properties tied to Employee Table.

public class Contractor : person {
    // Some properties tied to Contractor Table

DBSet<Person> People { get; set; }

Primary Key is derived from Person class.

Updated on 2013-06-27T21:35:51Z at 2013-06-27T21:35:51Z by AimTron
  • Devendra_Bhadauria
    52 Posts

    Re: .NET 4.0 EF5 TPT inheritance with DB2 10.1 and 10.1 data provider


    We don't have a Boolean type in DB2. That's why there is no DB2 type that directly maps to bool in .NET. Error suggests that we may be using Boolean in someways.

    Could you paste/share some code where/when exactly this happens?

    EF 5.0 Enums support feature can be used to have boolean type like behaviour. We introduced this support in Kepler (10.5.0) release:

    An application can write a wrapper property extending model on smallint (or other types) and have this Enum behaving like boolean.

    DB2 Enttiy Framework provider only supports Database First workflow. All Database tables involved in TPT should be preexisting.

    Hope this helps!

  • Anateus
    1 Post

    Re: .NET 4.0 EF5 TPT inheritance with DB2 10.1 and 10.1 data provider


    I have the exact same issue. I'm using .NET 3.5 with EF 1.0 and DB2 data provider 9.7 FP8.

    I try to execute a .Count() on a complex query represented by an ObjectQuery<T> object. This query returns normal results when iterating over the result set returned by the IEnumerable interface. But when I try to use the Count() extension method it fails with the message described above:

    {"ERROR [42704] [IBM][DB2] SQL0204N  \"BOOLEAN\" is an undefined name."}

    The actual SQL that the provider generates for the Count() has this content:

    GroupBy1.A1 AS C1
    FROM   ( SELECT CAST('t' AS boolean) AS X FROM SYSIBM.SYSDUMMY1 ) AS SingleRowTable1
     Count(Distinct1.A1) AS A1
     FROM ( ... complex query ...
      )  AS Distinct1
     )  AS Distinct1 ) AS GroupBy1 ON CAST('t' AS boolean) = CAST('t' AS Boolean)