Entity Framework generates short instead of int

橙三吉。 提交于 2019-12-06 03:45:55

问题


We are using Entity Framework database-first for our Oracle database.

For some reason Number(5) becomes Int16 - short

Max Number(5) value is 99999
Max Int16 value is 32767

Problem... is there a way to instruct the mapper to translate Number(5) to int32?


回答1:


Solved it, Added this to the web.config:

<oracle.dataaccess.client>
<settings>
<add name="int16" value="edmmapping number(4,0)" />
<add name="int32" value="edmmapping number(9,0)" />
</settings>
</oracle.dataaccess.client>

Recreated the Model with the *.edmx file and...

Now Number(5) is Int32 instead of Int16 and Number(10) is Int64 instead of Int32

I hope it'll help someone else in the future...




回答2:


Oracle with EntityFramework for me has always resulted in having a sheet of changes I have to apply to my edmx file after it's generated.

Aside from changing the column's dataType, I'd suggest manually editing the row's type in the edmx file and just remembering this is something you'll have to do everytime you re-generate




回答3:


For Oracle.ManagedDataAccess.Client, I try this work, and notice the question in top post comment:

<oracle.manageddataaccess.client>
    <version number="*"> 
      <edmMappings>
        <edmNumberMapping>
          <add NETType="int16" MinPrecision="2" MaxPrecision="4" DBType="Number" />
          <add NETType="int32" MinPrecision="5" MaxPrecision="9" DBType="Number" />
          <add NETType="int64" MinPrecision="10" MaxPrecision="19" DBType="Number" />
          <add NETType="bool" MinPrecision="1" MaxPrecision="1" DBType="Number" />
        </edmNumberMapping>
      </edmMappings>
    </version>
  </oracle.manageddataaccess.client>

`



来源:https://stackoverflow.com/questions/12339918/entity-framework-generates-short-instead-of-int

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!