0 Replies Latest reply: Apr 24, 2014 11:27 AM by 44456bed-b71c-4f61-a89a-e697037eaa90 RSS

    Entity Framework error Year, Month, and Day parameters describe an un-representable DateTime

    44456bed-b71c-4f61-a89a-e697037eaa90

      HI,

      I have problem with connecting Entity Framework with Oracle.

      I've got table:

      create table TEST_TABLE (

      ID NUMBER(5) NOT NULL,

      DATE_ADD DATE NOT NULL,

      DESCRIPTION VARCHAR2(10),

       

      CONSTRAINT TEST_TABLE_PK PRIMARY KEY(ID)

       

      );

      Insert into TEST_TABLE (ID, DATE_ADD, DESCRIPTION) VALUES (1,TO_DATE('1','J'), 'DESC1');

       

       

      I wrote a select to take DATETIME value (Gregorian), but in Oracle I have (julian) date, so I've got exception System.ArgumentOutOfRangeException 'Year, Month, and Day parameters describe an un-representable DateTime'.

      My generated class looks:

      public partial class TEST_TABLE

        {

        public short ID { get; set; }

        public System.DateTime DATE_ADD { get; set; }

        public string DESCRIPTION { get; set; }

        }

       

      I wrote query:

      using(Entities en52 = new Entities())

      {

        var temp = from e in en52.TEST_TABLE

        select e.DATE_ADD;

       

        foreach(var item in temp)

        {

        MessageBox.Show(item.ToString());

        }

      }

       

      When I have date -4712 from Oracle, then I will have an exception.

       

      SSDL content

      <EntityType Name="TEST_TABLE">

        <Key>

        <PropertyRef Name="ID" />

        </Key>

        <Property Name="ID" Type="number" Precision="5" Scale="0" Nullable="false" />

        <Property Name="DATE_ADD" Type="date" Nullable="false" />

        <Property Name="DESCRIPTION" Type="varchar2" MaxLength="10" />

      </EntityType>

       

      CSDL content

      <EntityType Name="TEST_TABLE">

        <Key>

        <PropertyRef Name="ID" />

        </Key>

        <Property Name="ID" Type="Int16" Nullable="false" />

        <Property Name="DATE_ADD" Type="DateTime" Nullable="false" />

        <Property Name="DESCRIPTION" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />

      </EntityType>

       

      C-S mapping content

      <EntitySetMapping Name="TEST_TABLE">

        <EntityTypeMapping TypeName="Model.TEST_TABLE">

        <MappingFragment StoreEntitySet="TEST_TABLE">

        <ScalarProperty Name="DESCRIPTION" ColumnName="DESCRIPTION" />

        <ScalarProperty Name="DATE_ADD" ColumnName="DATE_ADD" />

        <ScalarProperty Name="ID" ColumnName="ID" />

        </MappingFragment>

        </EntityTypeMapping>

      </EntitySetMapping>

       

       

      Can anybody help me resolve this problem?

      Thanks!