问题
We are using EF5 with Oracle[Oracle.manageddataaccess.client].Whenever I create/refresh edmx.I loose the property StoreGeneratedPattern="Identity". I had to set this manually for each and every Entity.
Is there any way to automate it or any other work around ? am I missing something here ?
We use VS2013,Below is the sample entity in the edmx after create.
<EntityType Name="ADDRESS">
<Key>
<PropertyRef Name="ADDRESS_ID" />
</Key>
<Property Name="ADDRESS_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="CLIENT_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="USER_ID" Type="number" Precision="38" Scale="0" />
<Property Name="ADDRESS_ACT_FLG" Type="number" Precision="38" Scale="0" />
<Property Name="ADDRESS_1" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_2" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_3" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_4" Type="varchar2" MaxLength="50" />
<Property Name="ADDRESS_SUFFIX" Type="char" MaxLength="2" />
<Property Name="COUNTY" Type="varchar2" MaxLength="50" />
<Property Name="CITY" Type="varchar2" MaxLength="50" />
<Property Name="STATE_PROVINCE" Type="varchar2" MaxLength="75" />
<Property Name="COUNTRY" Type="varchar2" MaxLength="50" />
<Property Name="POSTAL_CODE" Type="varchar2" MaxLength="10" />
<Property Name="ADDRESS_TYPE" Type="varchar2" MaxLength="2" />
<Property Name="PRIMARY_ADDRESS_IND" Type="number" Precision="38" Scale="0" />
<Property Name="CREATED_USER_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="CREATED_DATE" Type="timestamp" Precision="6" Nullable="false" />
<Property Name="MODIFIED_USER_ID" Type="number" Precision="38" Scale="0" Nullable="false" />
<Property Name="MODIFIED_DATE" Type="timestamp" Precision="6" Nullable="false" />
</EntityType>
回答1:
I have written a short blog post about it: http://blog.aitgmbh.de/2014/06/02/patch-for-entity-framework-models-based-on-oracle-databases/
There I also refer to a NuGet package that I have created: http://bit.ly/1hbxIsO
This adds MSBuild scripts that manipulate the edmx file automatically.
It basically lets you define which columns should be identity columns and ensures at every build that the StoreGeneratedPattern property of these identity columns is set to "Identity".
Update: The patch is now also available on GitHub.
来源:https://stackoverflow.com/questions/23661666/ef-5-with-oracle-edmx-storegeneratedpattern-identity-issue