Entity framework do not refreshes ID in entity after insert
Posted: Mon 04 Jan 2016 14:18
Hello
Need help on devart with entity framework 6.0(Fluent API) and oracle enterprise edition release 12.1.0.2.0 - 64bit
In database we are using sequence and trigger to insert id value for column on insert
and in application we are marking id property of entity as Identity using fluent API
Using above configuration whenever we insert model in database we get following error in application
Please suggest if I am missing any config in entity framework because of which entity framework is not refreshing model property in dbcontext
Thanks
Need help on devart with entity framework 6.0(Fluent API) and oracle enterprise edition release 12.1.0.2.0 - 64bit
In database we are using sequence and trigger to insert id value for column on insert
Code: Select all
CREATE OR REPLACE TRIGGER TEST_TRG
BEFORE INSERT ON TEST_TABLE
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
if :new.ID = 0 then
:new.ID := MYSEQUENCE.nextval;
end if;
END;
Code: Select all
this.Property(t => t.Id).HasColumnName("ID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
However in above config if we change DatabaseGeneratedOption to none, application adds model in database but do not refreshes id property in model. This implies there is no issue with trigger and sequence in databaseA null store-generated value was returned for a non-nullable member 'Id' of type Test
Please suggest if I am missing any config in entity framework because of which entity framework is not refreshing model property in dbcontext
Thanks