entity type mapping for SqlQuery method RRS feed

  • Question

  • I have a column name mapping defined in edmx file like below:

    <EntitySetMapping Name="ADJUSTER">
                <EntityTypeMapping TypeName="Entity.ADJUSTER">
                  <MappingFragment StoreEntitySet="TBL_ADJUSTER">
                    <ScalarProperty Name="ADJUSTER_EMPID" ColumnName="N_ADJUSTER_EMPID" />
                    <ScalarProperty Name="LAST_MODIFIED" ColumnName="T_LAST_MODIFIED" />
                    <ScalarProperty Name="REMARK" ColumnName="C_REMARK" />
                    <ScalarProperty Name="ADJUSTER_EVAL" ColumnName="C_ADJUSTER_EVAL" />
                    <ScalarProperty Name="COMP_ID" ColumnName="N_COMP_ID" />
                    <ScalarProperty Name="PHONENO" ColumnName="C_PHONENO" />
                    <ScalarProperty Name="REGISTRATIONNO" ColumnName="C_REGISTRATIONNO" />
                    <ScalarProperty Name="ADJUSTER_NME" ColumnName="C_ADJUSTER_NME" />
                    <ScalarProperty Name="ADJUSTER_CDE" ColumnName="C_ADJUSTER_CDE" />
                    <ScalarProperty Name="ADJUSTER_ID" ColumnName="N_ADJUSTER_ID" />

    while excuting SqlQuery: 
    var entity = tx.Context.ADJUSTER.SqlQuery("select * from tbl_adjuster").FirstOrDefault();

    it throws an exception:

    The data reader is incompatible with the specified 'Entity.ADJUSTER'. A member of the type, 'ADJUSTER_ID', does not have a corresponding column in the data reader with the same name.

    Seems that SqlQuery cannot map the column name automatically according to edmx.

    How to solve this issue?

    they say nothing last forever

    Tuesday, July 17, 2012 7:12 AM

All replies

  • Hi Del.piero,

    Welcome to the MSDN forum.

    Please try to exchange “*” for the specific column names to check if this error will appear.

    Have a nice day.

    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, July 18, 2012 7:23 AM