Just like this post : viewtopic.php?f=30&t=32292
I need help in using EF6 and Oracle Sequence object for insert/update a records with identity column.
Using Entity Developer 5.8.676
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Storage :
Code: Select all
<Key>
<PropertyRef Name="NO_INTERV_EXT" />
</Key>
<Property Name="NO_INTERV_EXT" Type="int64" Nullable="false" devart:DefaultValue="SEQ_NO_INTERV_EXT.NEXTVAL" StoreGeneratedPattern="Identity" />
Code: Select all
<Property Name="NOINTERVEXT" Type="Int64" Nullable="false" annotation:StoreGeneratedPattern="Identity" ed:ValidateRequired="true" ed:Guid="9a831fef-9385-453e-b73f-36ea2af80102" />
Code: Select all
<ScalarProperty Name="NOINTERVEXT" ColumnName="NO_INTERV_EXT" />
Code: Select all
SELECT SEQ_NO_INTERV_EXT.NEXTVAL FROM DUAL;
Code: Select all
var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
config.DmlOptions.InsertNullBehaviour = Devart.Data.Oracle.Entity.Configuration.InsertNullBehaviour.InsertDefaultOrNull;
Generated code for the column, in the configuration file looks like this :
Code: Select all
this
.Property(p => p.NOINTERVEXT)
.HasColumnName(@"NO_INTERV_EXT")
.IsRequired()
.HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)
.HasColumnType("int64");
I tried using DbMonitor to see the query, it sees my process but doesn't show any queries. I'm not sure what is up with that. I did add the reference to my main exe file and create an instance of OracleMonitor on which i set to IsActive = true. It only catches the connection creation but not usage (weird).Message=ORA-01400: cannot insert NULL into ("TFP"."TFP_E_INTERV_EXT"."NO_INTERV_EXT")
ORA-06512: at line 4
Offset=0
Source=Devart.Data.Oracle
StackTrace:
à Devart.Data.Oracle.an.d()
à Devart.Data.Oracle.cq.e()
à Devart.Data.Oracle.cq.a()
à Devart.Data.Oracle.i.a(cq A_0, Int32 A_1)
à Devart.Data.Oracle.i.a(Int32 A_0, cg A_1)
à Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
à Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
à Devart.Data.Oracle.Entity.g.a(CommandBehavior A_0)
à Devart.Data.Oracle.Entity.g.b(CommandBehavior A_0)
à System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
à System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
à System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
à System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
EDIT: Got DbMonitor to work, here's my query:
Code: Select all
DECLARE
updatedRowid ROWID;
BEGIN
INSERT INTO TFP_E_INTERV_EXT(NOM, PRENOM, NOM_RECH, PRENOM_RECH, GENRE_INTERV_EXT, NO_PROP_SYST_EVAL, NO_TEL_RESID, NO_TEL_BUR, AUT_REF, DATE_CREAT, UTIL_CREAT, DATE_MODIF, CODE_UTIL_MODIF, STATUT, NO_CLIENT_SYST_AUTRE, NOM_FORM, NO_TELECOPIE, ADR_ELECTRNQ, IND_LANG_FACT_RECU, IND_INTERURBAIN, MEDIA_PRIV_LET_NOT, AU_SOIN_DE, ANC_NO_PROP_SYST_EVAL, IND_EXCL_ROLE, IND_FUSIONNABLE, NO_INST_FINAN, NO_SUCC_INST_FINAN, ORG_APPARENTE)
VALUES (:p0, :p1, :p2, :p3, NULL, NULL, NULL, NULL, NULL, :p4, :p5, :p6, :p7, :p8, NULL, :p9, NULL, NULL, :p10, :p11, :p12, NULL, NULL, :p13, :p14, NULL, NULL, NULL)
RETURNING ROWID INTO updatedRowid;
OPEN :outParameter FOR SELECT NO_INTERV_EXT FROM TFP_E_INTERV_EXT WHERE ROWID = updatedRowid;
END;
Any help would be appreciated!
EDIT 2 :
If i add a Before Insert trigger, it works well. I was hoping i wouldn't have to add triggers tho...