6 Replies Latest reply on May 10, 2011 6:51 PM by 860903

    SQL parse error from EF <> ODP.NET

    ramsey
      Hi

      I have a simple program that works with DevArt and DataDirect providers but fails with ODP.NET provider.
      Error message:
      {"ORA-06550: line 1, column 9:\nPLS-00103: Encountered the symbol \"@\" when expecting one of the following:\n\n begin function pragma procedure subtype type <an identifier>\n <a double-quoted delimited-identifier> current cursor delete\n exists prior"}

      ODAC version: ODAC1120230Beta_EntityFramework
      dotNET version: 4
      Oracle version: 11.2.0.2

      When doing a SQL trace following query shows up at the database which cannot be parsed for obvious reasons.
      PARSE ERROR #392306000:len=100 dep=0 uid=63 oct=47 lid=63 tim=26525472453 err=6550
      declare @p int
      update "IMPL10"."ORDERS"
      set @p = 0
      where (("ORDER_ID" = :p0) and ("CCN" = :p1))
      Program:
              static void Main(string[] args)
              {
                  using (MyModelEntities ctx = new MyModelEntities())
                  {
                      SAMPLE_TYPES sampleType = ctx.SAMPLE_TYPES.First();

                      ORDER order = new ORDER();
                      order.STATUS = "Open";
                      order.ORDER_DATE = new System.DateTime(2010, 5, 18);
                      order.CCN = 1;

                      ctx.AddToORDERS(order);
                      ctx.SaveChanges();

                      SAMPLE sample = new SAMPLE
                      {
                          ORDER = order,
                          SAMPLE_TYPES = sampleType,
                          VOLUME = 100,
                          STATUS = "Created",
                          CCN = 1
                      };
                      ctx.AddToSAMPLES(sample);
                      ctx.SaveChanges();

                      ctx.Detach(sampleType);
                      ctx.Detach(sample);
                      ctx.Detach(order);
                  }
      Any feedback is very welcome.

      Thanks and regards,
      Bidu
        • 1. Re: SQL parse error from EF <> ODP.NET
          15208
          The ctx.AddToORDERS(order) and ctx.AddToSAMPLES(sample) should make the provider generate and execute INSERT statements
          behind the scene at ctx.SaveChanges(). But the error you provided looks like from an UPDATE statement.

          Is the test code you provided complete?
          Can you also provde a script that creates tables and/or types to reproduce the error?
          • 2. Re: SQL parse error from EF <> ODP.NET
            ramsey
            Hi,

            Sorry for my late response.

            Here's the complete code.
            I can't see any reason why the provider should generate this syntactically incorrect update statement.

            Thanks!

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using Oracle.DataAccess.Client;
            using System.Data.EntityClient;
            using System.Data;

            namespace ODPIssue
            {
                class Program
                {
                    static void Main(string[] args)
                    {
                        using (MyModelEntities ctx = new MyModelEntities())
                        {
                            // opening entity connect so it is keept open until context is disposed
                            EntityConnection eConn = ctx.Connection as EntityConnection;
                            if (ctx.Connection.State != ConnectionState.Open)
                            {
                                ctx.Connection.Open();
                            }
                            // activate SQL trace
                            OracleConnection oConn = eConn.StoreConnection as OracleConnection;
                            OracleCommand oCmd = new OracleCommand("begin dbms_monitor.session_trace_enable(null, null, true, false); end;", oConn);
                            oCmd.ExecuteNonQuery();

                            SAMPLE_TYPES sampleType = ctx.SAMPLE_TYPES.First();

                            ORDER order = new ORDER();
                            order.STATUS = "Open";
                            order.ORDER_DATE = new System.DateTime(2010, 5, 18);
                            order.CCN = 1;

                            ctx.AddToORDERS(order);
                            ctx.SaveChanges();

                            SAMPLE sample = new SAMPLE
                            {
                                ORDER = order,
                                SAMPLE_TYPES = sampleType,
                                VOLUME = 100,
                                STATUS = "Created",
                                CCN = 1
                            };
                            ctx.AddToSAMPLES(sample);
                            ctx.SaveChanges();

                            ctx.Detach(sampleType);
                            ctx.Detach(sample);
                            ctx.Detach(order);
                        }
                    }
                }
            }
            • 3. Re: SQL parse error from EF <> ODP.NET
              ramsey
              And here's the EDMX file is use:
              <?xml version="1.0" encoding="utf-8"?>
              <edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
                <!-- EF Runtime content -->
                <edmx:Runtime>
                  <!-- SSDL content -->
                  <edmx:StorageModels>
                  <Schema Namespace="MyModel.Store" Alias="Self" Provider="Oracle.DataAccess.Client" ProviderManifestToken="11g" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
                      <EntityContainer Name="MyModelStoreContainer">
                        <EntitySet Name="ANALYTES" EntityType="MyModel.Store.ANALYTES" store:Type="Tables" Schema="IMPL10" />
                        <EntitySet Name="ORDERS" EntityType="MyModel.Store.ORDERS" store:Type="Tables" Schema="IMPL10" />
                        <EntitySet Name="RESULTS" EntityType="MyModel.Store.RESULTS" store:Type="Tables" Schema="IMPL10" />
                        <EntitySet Name="SAMPLES" EntityType="MyModel.Store.SAMPLES" store:Type="Tables" Schema="IMPL10" />
                        <EntitySet Name="SAMPLE_TYPES" EntityType="MyModel.Store.SAMPLE_TYPES" store:Type="Tables" Schema="IMPL10" />
                        <EntitySet Name="TESTS" EntityType="MyModel.Store.TESTS" store:Type="Tables" Schema="IMPL10" />
                        <AssociationSet Name="RESULTS_FK_01" Association="MyModel.Store.RESULTS_FK_01">
                          <End Role="TESTS" EntitySet="TESTS" />
                          <End Role="RESULTS" EntitySet="RESULTS" />
                        </AssociationSet>
                        <AssociationSet Name="SAMPLES_FK_01" Association="MyModel.Store.SAMPLES_FK_01">
                          <End Role="ORDERS" EntitySet="ORDERS" />
                          <End Role="SAMPLES" EntitySet="SAMPLES" />
                        </AssociationSet>
                        <AssociationSet Name="SAMPLES_FK_02" Association="MyModel.Store.SAMPLES_FK_02">
                          <End Role="SAMPLE_TYPES" EntitySet="SAMPLE_TYPES" />
                          <End Role="SAMPLES" EntitySet="SAMPLES" />
                        </AssociationSet>
                        <AssociationSet Name="TESTS_FK_01" Association="MyModel.Store.TESTS_FK_01">
                          <End Role="SAMPLES" EntitySet="SAMPLES" />
                          <End Role="TESTS" EntitySet="TESTS" />
                        </AssociationSet>
                        <AssociationSet Name="TESTS_FK_02" Association="MyModel.Store.TESTS_FK_02">
                          <End Role="ANALYTES" EntitySet="ANALYTES" />
                          <End Role="TESTS" EntitySet="TESTS" />
                        </AssociationSet>
                      </EntityContainer>
                      <EntityType Name="ANALYTES">
                        <Key>
                          <PropertyRef Name="ANALYTE_ID" />
                        </Key>
                        <Property Name="ANALYTE_ID" Type="number" Nullable="false" Precision="3" StoreGeneratedPattern="Identity" />
                        <Property Name="DESCRIPTION" Type="varchar2" Nullable="false" MaxLength="30" />
                        <Property Name="CCN" Type="number" Nullable="false" />
                      </EntityType>
                      <EntityType Name="ORDERS">
                        <Key>
                          <PropertyRef Name="ORDER_ID" />
                        </Key>
                        <Property Name="ORDER_ID" Type="number" Nullable="false" Precision="8" StoreGeneratedPattern="Identity" />
                        <Property Name="STATUS" Type="varchar2" Nullable="false" MaxLength="10" />
                        <Property Name="ORDER_DATE" Type="date" Nullable="false" />
                        <Property Name="CCN" Type="number" Nullable="false" />
                      </EntityType>
                      <EntityType Name="RESULTS">
                        <Key>
                          <PropertyRef Name="RESULT_ID" />
                        </Key>
                        <Property Name="RESULT_ID" Type="number" Nullable="false" Precision="8" StoreGeneratedPattern="Identity" />
                        <Property Name="TEST_ID" Type="number" Nullable="false" Precision="8" />
                        <Property Name="MEASUREMENT" Type="number" Nullable="false" Precision="5" />
                        <Property Name="CCN" Type="number" Nullable="false" />
                      </EntityType>
                      <EntityType Name="SAMPLES">
                        <Key>
                          <PropertyRef Name="SAMPLE_ID" />
                        </Key>
                        <Property Name="SAMPLE_ID" Type="number" Nullable="false" Precision="8" StoreGeneratedPattern="Identity" />
                        <Property Name="ORDER_ID" Type="number" Nullable="false" Precision="8" />
                        <Property Name="SAMPLE_TYPE_ID" Type="number" Nullable="false" Precision="3" />
                        <Property Name="VOLUME" Type="number" Nullable="false" Precision="10" Scale="2" />
                        <Property Name="STATUS" Type="varchar2" Nullable="false" MaxLength="10" />
                        <Property Name="CCN" Type="number" Nullable="false" />
                      </EntityType>
                      <EntityType Name="SAMPLE_TYPES">
                        <Key>
                          <PropertyRef Name="SAMPLE_TYPE_ID" />
                        </Key>
                        <Property Name="SAMPLE_TYPE_ID" Type="number" Nullable="false" Precision="3" StoreGeneratedPattern="Identity" />
                        <Property Name="DESCRIPTION" Type="varchar2" Nullable="false" MaxLength="30" />
                        <Property Name="CCN" Type="number" Nullable="false" />
                      </EntityType>
                      <EntityType Name="TESTS">
                        <Key>
                          <PropertyRef Name="TEST_ID" />
                        </Key>
                        <Property Name="TEST_ID" Type="number" Nullable="false" Precision="8" StoreGeneratedPattern="Identity" />
                        <Property Name="SAMPLE_ID" Type="number" Nullable="false" Precision="8" />
                        <Property Name="ANALYTE_ID" Type="number" Nullable="false" Precision="3" />
                        <Property Name="STATUS" Type="varchar2" Nullable="false" MaxLength="10" />
                        <Property Name="CCN" Type="number" Nullable="false" />
                      </EntityType>
                      <Association Name="RESULTS_FK_01">
                        <End Role="TESTS" Type="MyModel.Store.TESTS" Multiplicity="1" />
                        <End Role="RESULTS" Type="MyModel.Store.RESULTS" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="TESTS">
                            <PropertyRef Name="TEST_ID" />
                          </Principal>
                          <Dependent Role="RESULTS">
                            <PropertyRef Name="TEST_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="SAMPLES_FK_01">
                        <End Role="ORDERS" Type="MyModel.Store.ORDERS" Multiplicity="1" />
                        <End Role="SAMPLES" Type="MyModel.Store.SAMPLES" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="ORDERS">
                            <PropertyRef Name="ORDER_ID" />
                          </Principal>
                          <Dependent Role="SAMPLES">
                            <PropertyRef Name="ORDER_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="SAMPLES_FK_02">
                        <End Role="SAMPLE_TYPES" Type="MyModel.Store.SAMPLE_TYPES" Multiplicity="1" />
                        <End Role="SAMPLES" Type="MyModel.Store.SAMPLES" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="SAMPLE_TYPES">
                            <PropertyRef Name="SAMPLE_TYPE_ID" />
                          </Principal>
                          <Dependent Role="SAMPLES">
                            <PropertyRef Name="SAMPLE_TYPE_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="TESTS_FK_01">
                        <End Role="SAMPLES" Type="MyModel.Store.SAMPLES" Multiplicity="1" />
                        <End Role="TESTS" Type="MyModel.Store.TESTS" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="SAMPLES">
                            <PropertyRef Name="SAMPLE_ID" />
                          </Principal>
                          <Dependent Role="TESTS">
                            <PropertyRef Name="SAMPLE_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="TESTS_FK_02">
                        <End Role="ANALYTES" Type="MyModel.Store.ANALYTES" Multiplicity="1" />
                        <End Role="TESTS" Type="MyModel.Store.TESTS" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="ANALYTES">
                            <PropertyRef Name="ANALYTE_ID" />
                          </Principal>
                          <Dependent Role="TESTS">
                            <PropertyRef Name="ANALYTE_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                    </Schema></edmx:StorageModels>
                  <!-- CSDL content -->
                  <edmx:ConceptualModels>
                    <Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" xmlns:cg="http://schemas.microsoft.com/ado/2006/04/codegeneration" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" Namespace="MyModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
                      <EntityContainer Name="MyModelEntities" annotation:LazyLoadingEnabled="true">
                        <EntitySet Name="ANALYTES" EntityType="MyModel.ANALYTE" />
                        <EntitySet Name="ORDERS" EntityType="MyModel.ORDER" />
                        <EntitySet Name="RESULTS" EntityType="MyModel.RESULT" />
                        <EntitySet Name="SAMPLES" EntityType="MyModel.SAMPLE" />
                        <EntitySet Name="SAMPLE_TYPES" EntityType="MyModel.SAMPLE_TYPES" />
                        <EntitySet Name="TESTS" EntityType="MyModel.TEST" />
                        <AssociationSet Name="TESTS_FK_02" Association="MyModel.TESTS_FK_02">
                          <End Role="ANALYTE" EntitySet="ANALYTES" />
                          <End Role="TEST" EntitySet="TESTS" />
                        </AssociationSet>
                        <AssociationSet Name="SAMPLES_FK_01" Association="MyModel.SAMPLES_FK_01">
                          <End Role="ORDER" EntitySet="ORDERS" />
                          <End Role="SAMPLE" EntitySet="SAMPLES" />
                        </AssociationSet>
                        <AssociationSet Name="RESULTS_FK_01" Association="MyModel.RESULTS_FK_01">
                          <End Role="TEST" EntitySet="TESTS" />
                          <End Role="RESULT" EntitySet="RESULTS" />
                        </AssociationSet>
                        <AssociationSet Name="SAMPLES_FK_02" Association="MyModel.SAMPLES_FK_02">
                          <End Role="SAMPLE_TYPES" EntitySet="SAMPLE_TYPES" />
                          <End Role="SAMPLE" EntitySet="SAMPLES" />
                        </AssociationSet>
                        <AssociationSet Name="TESTS_FK_01" Association="MyModel.TESTS_FK_01">
                          <End Role="SAMPLE" EntitySet="SAMPLES" />
                          <End Role="TEST" EntitySet="TESTS" />
                        </AssociationSet>
                      </EntityContainer>
                      <EntityType Name="ANALYTE">
                        <Key>
                          <PropertyRef Name="ANALYTE_ID" />
                        </Key>
                        <Property Type="Decimal" Name="ANALYTE_ID" Nullable="false" Precision="3" Scale="0" annotation:StoreGeneratedPattern="Identity" />
                        <Property Type="String" Name="DESCRIPTION" Nullable="false" MaxLength="30" FixedLength="false" Unicode="false" />
                        <Property Type="Decimal" Name="CCN" Nullable="false" Precision="38" Scale="0" ConcurrencyMode="Fixed" />
                        <NavigationProperty Name="TESTS" Relationship="MyModel.TESTS_FK_02" FromRole="ANALYTE" ToRole="TEST" />
                      </EntityType>
                      <EntityType Name="ORDER">
                        <Key>
                          <PropertyRef Name="ORDER_ID" />
                        </Key>
                        <Property Type="Decimal" Name="ORDER_ID" Nullable="false" Precision="8" Scale="0" annotation:StoreGeneratedPattern="Identity" />
                        <Property Type="String" Name="STATUS" Nullable="false" MaxLength="10" FixedLength="false" Unicode="false" />
                        <Property Type="DateTime" Name="ORDER_DATE" Nullable="false" />
                        <Property Type="Decimal" Name="CCN" Nullable="false" Precision="38" Scale="0" ConcurrencyMode="Fixed" />
                        <NavigationProperty Name="SAMPLES" Relationship="MyModel.SAMPLES_FK_01" FromRole="ORDER" ToRole="SAMPLE" />
                      </EntityType>
                      <EntityType Name="RESULT">
                        <Key>
                          <PropertyRef Name="RESULT_ID" />
                        </Key>
                        <Property Type="Decimal" Name="RESULT_ID" Nullable="false" Precision="8" Scale="0" annotation:StoreGeneratedPattern="Identity" />
                        <Property Type="Decimal" Name="TEST_ID" Nullable="false" Precision="8" Scale="0" />
                        <Property Type="Decimal" Name="MEASUREMENT" Nullable="false" Precision="5" Scale="0" />
                        <Property Type="Decimal" Name="CCN" Nullable="false" Precision="38" Scale="0" ConcurrencyMode="Fixed" />
                        <NavigationProperty Name="TEST" Relationship="MyModel.RESULTS_FK_01" FromRole="RESULT" ToRole="TEST" />
                      </EntityType>
                      <EntityType Name="SAMPLE">
                        <Key>
                          <PropertyRef Name="SAMPLE_ID" />
                        </Key>
                        <Property Type="Decimal" Name="SAMPLE_ID" Nullable="false" Precision="8" Scale="0" annotation:StoreGeneratedPattern="Identity" />
                        <Property Type="Decimal" Name="ORDER_ID" Nullable="false" Precision="8" Scale="0" />
                        <Property Type="Decimal" Name="SAMPLE_TYPE_ID" Nullable="false" Precision="3" Scale="0" />
                        <Property Type="Decimal" Name="VOLUME" Nullable="false" Precision="10" Scale="2" />
                        <Property Type="String" Name="STATUS" Nullable="false" MaxLength="10" FixedLength="false" Unicode="false" />
                        <Property Type="Decimal" Name="CCN" Nullable="false" Precision="38" Scale="0" ConcurrencyMode="Fixed" />
                        <NavigationProperty Name="ORDER" Relationship="MyModel.SAMPLES_FK_01" FromRole="SAMPLE" ToRole="ORDER" />
                        <NavigationProperty Name="SAMPLE_TYPES" Relationship="MyModel.SAMPLES_FK_02" FromRole="SAMPLE" ToRole="SAMPLE_TYPES" />
                        <NavigationProperty Name="TESTS" Relationship="MyModel.TESTS_FK_01" FromRole="SAMPLE" ToRole="TEST" />
                      </EntityType>
                      <EntityType Name="SAMPLE_TYPES">
                        <Key>
                          <PropertyRef Name="SAMPLE_TYPE_ID" />
                        </Key>
                        <Property Type="Decimal" Name="SAMPLE_TYPE_ID" Nullable="false" Precision="3" Scale="0" annotation:StoreGeneratedPattern="Identity" />
                        <Property Type="String" Name="DESCRIPTION" Nullable="false" MaxLength="30" FixedLength="false" Unicode="false" />
                        <Property Type="Decimal" Name="CCN" Nullable="false" Precision="38" Scale="0" ConcurrencyMode="Fixed" />
                        <NavigationProperty Name="SAMPLES" Relationship="MyModel.SAMPLES_FK_02" FromRole="SAMPLE_TYPES" ToRole="SAMPLE" />
                      </EntityType>
                      <EntityType Name="TEST">
                        <Key>
                          <PropertyRef Name="TEST_ID" />
                        </Key>
                        <Property Type="Decimal" Name="TEST_ID" Nullable="false" Precision="8" Scale="0" annotation:StoreGeneratedPattern="Identity" />
                        <Property Type="Decimal" Name="SAMPLE_ID" Nullable="false" Precision="8" Scale="0" />
                        <Property Type="Decimal" Name="ANALYTE_ID" Nullable="false" Precision="3" Scale="0" />
                        <Property Type="String" Name="STATUS" Nullable="false" MaxLength="10" FixedLength="false" Unicode="false" />
                        <Property Type="Decimal" Name="CCN" Nullable="false" Precision="38" Scale="0" ConcurrencyMode="Fixed" />
                        <NavigationProperty Name="ANALYTE" Relationship="MyModel.TESTS_FK_02" FromRole="TEST" ToRole="ANALYTE" />
                        <NavigationProperty Name="RESULTS" Relationship="MyModel.RESULTS_FK_01" FromRole="TEST" ToRole="RESULT" />
                        <NavigationProperty Name="SAMPLE" Relationship="MyModel.TESTS_FK_01" FromRole="TEST" ToRole="SAMPLE" />
                      </EntityType>
                      <Association Name="TESTS_FK_02">
                        <End Type="MyModel.ANALYTE" Role="ANALYTE" Multiplicity="1" />
                        <End Type="MyModel.TEST" Role="TEST" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="ANALYTE">
                            <PropertyRef Name="ANALYTE_ID" />
                          </Principal>
                          <Dependent Role="TEST">
                            <PropertyRef Name="ANALYTE_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="SAMPLES_FK_01">
                        <End Type="MyModel.ORDER" Role="ORDER" Multiplicity="1" />
                        <End Type="MyModel.SAMPLE" Role="SAMPLE" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="ORDER">
                            <PropertyRef Name="ORDER_ID" />
                          </Principal>
                          <Dependent Role="SAMPLE">
                            <PropertyRef Name="ORDER_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="RESULTS_FK_01">
                        <End Type="MyModel.TEST" Role="TEST" Multiplicity="1" />
                        <End Type="MyModel.RESULT" Role="RESULT" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="TEST">
                            <PropertyRef Name="TEST_ID" />
                          </Principal>
                          <Dependent Role="RESULT">
                            <PropertyRef Name="TEST_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="SAMPLES_FK_02">
                        <End Type="MyModel.SAMPLE_TYPES" Role="SAMPLE_TYPES" Multiplicity="1" />
                        <End Type="MyModel.SAMPLE" Role="SAMPLE" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="SAMPLE_TYPES">
                            <PropertyRef Name="SAMPLE_TYPE_ID" />
                          </Principal>
                          <Dependent Role="SAMPLE">
                            <PropertyRef Name="SAMPLE_TYPE_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      <Association Name="TESTS_FK_01">
                        <End Type="MyModel.SAMPLE" Role="SAMPLE" Multiplicity="1" />
                        <End Type="MyModel.TEST" Role="TEST" Multiplicity="*" />
                        <ReferentialConstraint>
                          <Principal Role="SAMPLE">
                            <PropertyRef Name="SAMPLE_ID" />
                          </Principal>
                          <Dependent Role="TEST">
                            <PropertyRef Name="SAMPLE_ID" />
                          </Dependent>
                        </ReferentialConstraint>
                      </Association>
                      </Schema>
                  </edmx:ConceptualModels>
                  <!-- C-S mapping content -->
                  <edmx:Mappings>
                    <Mapping xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs" Space="C-S">
                      <Alias Key="Model" Value="MyModel" />
                      <Alias Key="Target" Value="MyModel.Store" />
                      <EntityContainerMapping CdmEntityContainer="MyModelEntities" StorageEntityContainer="MyModelStoreContainer">
                        <EntitySetMapping Name="ANALYTES">
                          <EntityTypeMapping TypeName="MyModel.ANALYTE">
                            <MappingFragment StoreEntitySet="ANALYTES">
                              <ScalarProperty Name="CCN" ColumnName="CCN" />
                              <ScalarProperty Name="DESCRIPTION" ColumnName="DESCRIPTION" />
                              <ScalarProperty Name="ANALYTE_ID" ColumnName="ANALYTE_ID" />
                            </MappingFragment>
                          </EntityTypeMapping>
                        </EntitySetMapping>
                        <EntitySetMapping Name="ORDERS">
                          <EntityTypeMapping TypeName="MyModel.ORDER">
                            <MappingFragment StoreEntitySet="ORDERS">
                              <ScalarProperty Name="CCN" ColumnName="CCN" />
                              <ScalarProperty Name="ORDER_DATE" ColumnName="ORDER_DATE" />
                              <ScalarProperty Name="STATUS" ColumnName="STATUS" />
                              <ScalarProperty Name="ORDER_ID" ColumnName="ORDER_ID" />
                            </MappingFragment>
                          </EntityTypeMapping>
                        </EntitySetMapping>
                        <EntitySetMapping Name="RESULTS">
                          <EntityTypeMapping TypeName="MyModel.RESULT">
                            <MappingFragment StoreEntitySet="RESULTS">
                              <ScalarProperty Name="CCN" ColumnName="CCN" />
                              <ScalarProperty Name="MEASUREMENT" ColumnName="MEASUREMENT" />
                              <ScalarProperty Name="TEST_ID" ColumnName="TEST_ID" />
                              <ScalarProperty Name="RESULT_ID" ColumnName="RESULT_ID" />
                            </MappingFragment>
                          </EntityTypeMapping>
                        </EntitySetMapping>
                        <EntitySetMapping Name="SAMPLES">
                          <EntityTypeMapping TypeName="MyModel.SAMPLE">
                            <MappingFragment StoreEntitySet="SAMPLES">
                              <ScalarProperty Name="CCN" ColumnName="CCN" />
                              <ScalarProperty Name="STATUS" ColumnName="STATUS" />
                              <ScalarProperty Name="VOLUME" ColumnName="VOLUME" />
                              <ScalarProperty Name="SAMPLE_TYPE_ID" ColumnName="SAMPLE_TYPE_ID" />
                              <ScalarProperty Name="ORDER_ID" ColumnName="ORDER_ID" />
                              <ScalarProperty Name="SAMPLE_ID" ColumnName="SAMPLE_ID" />
                            </MappingFragment>
                          </EntityTypeMapping>
                        </EntitySetMapping>
                        <EntitySetMapping Name="SAMPLE_TYPES">
                          <EntityTypeMapping TypeName="MyModel.SAMPLE_TYPES">
                            <MappingFragment StoreEntitySet="SAMPLE_TYPES">
                              <ScalarProperty Name="CCN" ColumnName="CCN" />
                              <ScalarProperty Name="DESCRIPTION" ColumnName="DESCRIPTION" />
                              <ScalarProperty Name="SAMPLE_TYPE_ID" ColumnName="SAMPLE_TYPE_ID" />
                            </MappingFragment>
                          </EntityTypeMapping>
                        </EntitySetMapping>
                        <EntitySetMapping Name="TESTS">
                          <EntityTypeMapping TypeName="MyModel.TEST">
                            <MappingFragment StoreEntitySet="TESTS">
                              <ScalarProperty Name="CCN" ColumnName="CCN" />
                              <ScalarProperty Name="STATUS" ColumnName="STATUS" />
                              <ScalarProperty Name="ANALYTE_ID" ColumnName="ANALYTE_ID" />
                              <ScalarProperty Name="SAMPLE_ID" ColumnName="SAMPLE_ID" />
                              <ScalarProperty Name="TEST_ID" ColumnName="TEST_ID" />
                            </MappingFragment>
                          </EntityTypeMapping>
                        </EntitySetMapping>
                      </EntityContainerMapping>
                    </Mapping>
                  </edmx:Mappings>
                </edmx:Runtime>
                <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
                <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
                  <edmx:Connection>
                    <DesignerInfoPropertySet>
                      <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
                    </DesignerInfoPropertySet>
                  </edmx:Connection>
                  <edmx:Options>
                    <DesignerInfoPropertySet>
                      <DesignerProperty Name="ValidateOnBuild" Value="true" />
                      <DesignerProperty Name="EnablePluralization" Value="True" />
                      <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
                      <DesignerProperty Name="DefaultDatabaseSchema" Value="IMPL10" />
                      <DesignerProperty Name="DDLGenerationTemplate" Value="$(VSEFTools)\DBGen\SSDLToOracle.tt" />
                    </DesignerInfoPropertySet>
                  </edmx:Options>
                  <!-- Diagram content (shape and connector positions) -->
                  <edmx:Diagrams>
                    <Diagram Name="MyModel" >
                      <EntityTypeShape EntityType="MyModel.ANALYTE" Width="1.5" PointX="5.25" PointY="4.25" Height="1.5923063151041674" />
                      <EntityTypeShape EntityType="MyModel.ORDER" Width="1.5" PointX="0.75" PointY="1.25" Height="1.7566536458333388" />
                      <EntityTypeShape EntityType="MyModel.RESULT" Width="1.5" PointX="7.5" PointY="1.25" Height="1.7566536458333388" />
                      <EntityTypeShape EntityType="MyModel.SAMPLE" Width="1.5" PointX="3" PointY="1" Height="2.4140429687500067" />
                      <EntityTypeShape EntityType="MyModel.SAMPLE_TYPES" Width="1.5" PointX="2.875" PointY="4.25" Height="1.5923063151041674" />
                      <EntityTypeShape EntityType="MyModel.TEST" Width="1.5" PointX="5.25" PointY="1" Height="2.2496956380208246" />
                      <AssociationConnector Association="MyModel.TESTS_FK_02" >
                        <ConnectorPoint PointX="6" PointY="4.25" />
                        <ConnectorPoint PointX="6" PointY="3.2496956380208246" />
                      </AssociationConnector>
                      <AssociationConnector Association="MyModel.SAMPLES_FK_01" >
                        <ConnectorPoint PointX="2.25" PointY="2.1283268229166694" />
                        <ConnectorPoint PointX="3" PointY="2.1283268229166694" />
                      </AssociationConnector>
                      <AssociationConnector Association="MyModel.RESULTS_FK_01" >
                        <ConnectorPoint PointX="6.75" PointY="2.1283268229166694" />
                        <ConnectorPoint PointX="7.5" PointY="2.1283268229166694" />
                      </AssociationConnector>
                      <AssociationConnector Association="MyModel.SAMPLES_FK_02" >
                        <ConnectorPoint PointX="3.6875" PointY="4.25" />
                        <ConnectorPoint PointX="3.6875" PointY="3.4140429687500067" />
                      </AssociationConnector>
                      <AssociationConnector Association="MyModel.TESTS_FK_01" >
                        <ConnectorPoint PointX="4.5" PointY="2.1248478190104123" />
                        <ConnectorPoint PointX="5.25" PointY="2.1248478190104123" />
                      </AssociationConnector>
                    </Diagram>
                  </edmx:Diagrams>
                </edmx:Designer>
              </edmx:Edmx>
              • 4. Re: SQL parse error from EF <> ODP.NET
                ramsey
                And all the DDL/DMLs you need to run the example:
                -- run as SYSDBA
                create tablespace ts_impl10
                  datafile 'D:\oradata\ROKITC\impl10.dbf' size 64M autoextend on next 8M maxsize 8192M
                  extent management local autoallocate
                  segment space management auto
                ;
                create user impl10
                  identified by impl10
                  default tablespace ts_impl10
                  temporary tablespace temp
                  quota unlimited on ts_impl10
                ;
                grant connect to impl10;
                grant create table to impl10;
                grant create sequence to impl10;
                grant create trigger to impl10;
                grant create type to impl10;
                grant create procedure to impl10;
                grant create table to impl10;
                grant create table to impl10;
                grant create synonym to impl10;
                grant create view to impl10;
                grant create public synonym to impl10;
                grant drop public synonym to impl10;
                -- for testing only
                grant dba to impl10;
                grant execute on dbms_monitor to impl10;


                create table orders (
                    order_id number(8, 0) not null
                  , status varchar2(10) not null
                  , order_date date not null
                  , ccn number(38, 0) not null
                );

                create table samples (
                    sample_id number(8, 0) not null
                  , order_id number(8, 0) not null
                  , sample_type_id number(3, 0) not null
                  , volume number(10, 2) not null
                  , status varchar2(10) not null
                  , ccn number(38, 0) not null
                );

                create table sample_types (
                    sample_type_id number(3, 0) not null
                  , description varchar2(30) not null
                  , ccn number(38, 0) not null
                );

                create table tests (
                    test_id number(8, 0) not null
                  , sample_id number(8, 0) not null
                  , analyte_id number(3, 0) not null
                  , status varchar2(10) not null
                  , ccn number(38, 0) not null
                );

                create table analytes (
                    analyte_id number(3, 0) not null
                  , description varchar2(30) not null
                  , ccn number(38, 0) not null
                );

                create table results (
                    result_id number(8, 0) not null
                  , test_id number(8, 0) not null
                  , measurement number(5, 0) not null
                  , ccn number(38, 0) not null
                );

                alter table orders add constraint orders_pk
                     primary key (order_id)
                ;

                alter table orders add constraint orders_chk_01
                  check (status in ('Open', 'Completed'))
                ;

                alter table samples add constraint samples_pk
                     primary key (sample_id)
                ;

                alter table samples add constraint samples_chk_01
                  check (status in ('Created', 'Processing', 'Completed'))
                ;

                alter table sample_types add constraint sample_types_pk
                  primary key (sample_type_id)
                ;

                alter table tests add constraint tests_pk
                  primary key (test_id)
                ;

                alter table tests add constraint tests_chk_01
                  check (status in ('Created', 'Completed'))
                ;

                alter table analytes add constraint analytes_pk
                  primary key (analyte_id)
                ;

                alter table results add constraints results_pk
                  primary key (result_id)
                ;

                alter table samples add constraint samples_fk_01
                  foreign key (order_id) references orders (order_id)
                ;

                alter table samples add constraint samples_fk_02
                  foreign key (sample_type_id) references sample_types (sample_type_id)
                ;

                alter table tests add constraint tests_fk_01
                  foreign key (sample_id) references samples (sample_id)
                ;

                alter table tests add constraint tests_fk_02
                  foreign key (analyte_id) references analytes (analyte_id)
                ;

                alter table results add constraint results_fk_01
                  foreign key (test_id) references tests (test_id)
                ;

                create index samples_idx_01 on samples (order_id);

                create index samples_idx_02 on samples (sample_type_id);

                create index tests_idx_01 on tests (sample_id);

                create index tests_idx_02 on tests (analyte_id);

                create index results_idx_01 on results (test_id);

                create sequence orders_seq
                  cache 50
                  noorder
                ;

                create sequence samples_seq
                  cache 100
                  noorder
                ;

                create sequence sample_types_seq
                  cache 10
                  noorder
                ;

                create sequence tests_seq
                  cache 1000
                  noorder
                ;

                create sequence analytes_seq
                  cache 10
                  noorder
                ;

                create sequence results_seq
                  cache 1000
                  noorder
                ;

                create or replace trigger orders_trg
                  before insert on orders
                  for each row
                declare
                begin
                  :new.order_id := orders_seq.nextval;
                end orders_trg;
                /

                create or replace trigger samples_trg
                  before insert on samples
                  for each row
                declare
                begin
                  :new.sample_id := samples_seq.nextval;
                end samples_trg;
                /

                create or replace trigger sample_types_trg
                  before insert on sample_types
                  for each row
                declare
                begin
                  :new.sample_type_id := sample_types_seq.nextval;
                end sample_types_trg;
                /

                create or replace trigger tests_trg
                  before insert on tests
                  for each row
                declare
                begin
                  :new.test_id := tests_seq.nextval;
                end tests_trg;
                /

                create or replace trigger analytes_trg
                  before insert on analytes
                  for each row
                declare
                begin
                  :new.analyte_id := analytes_seq.nextval;
                end analytes_trg;
                /

                create or replace trigger results_trg
                  before insert on results
                  for each row
                declare
                begin
                  :new.result_id := results_seq.nextval;
                end results_trg;
                /

                insert into sample_types (description, ccn) values ('Urine', 1);
                insert into sample_types (description, ccn) values ('Serum', 1);
                insert into sample_types (description, ccn) values ('SuperNatant', 1);
                insert into sample_types (description, ccn) values ('WholeBlood', 1);
                commit;
                insert into analytes (description, ccn) values ('Sodium', 1);
                insert into analytes (description, ccn) values ('Potassium', 1);
                insert into analytes (description, ccn) values ('Glucose', 1);
                insert into analytes (description, ccn) values ('Fibrinogen', 1);
                insert into analytes (description, ccn) values ('Homocysteine', 1);
                commit;
                • 5. Re: SQL parse error from EF <> ODP.NET
                  15208
                  Thank you very much for the script and test code.
                  Somehow I got "ORA-02291: integrity constraint (IMPL10.SAMPLES_FK_01)
                  violated - parent key not found" error at ctx.SaveChanges() for ctx.AddToSAMPLES(sample) and
                  could not reproduce the error you mentioned.
                  Would you please help more to reproduce the said parse error?
                  • 6. Re: SQL parse error from EF <> ODP.NET
                    860903
                    I have noticed the same issue (generating similar sql / parsing errors).

                    It appears to only happen when you call ctx.SaveChanges when a dependent object has been updated, but the parent has not. In your case, I assume that the second call to SaveChanges is the one prodicuing the problem because the SAMPLE entity will be the only entity being added (and the parent "ORDER" has already been persisted to the db). If you were to remove the first call to SaveChanges I think the code may work correctly.

                    Of course, there are many instances where you need to save dependent objects independently of the parent, so I hope this issue gets resolved.