I wrote a simple test program which will access the default HR model on an Oracle Express in direct mode using DevArt dotConnect for Oracle v. 6.8.0.350:
using (var ctx = new HREntities())
{
var locNew = new LOCATION();
locNew.CITY = "Magdeburg";
ctx.LOCATIONs.AddObject(locNew);
ctx.SaveChanges();
// will output 0; in database ID is generated
Console.WriteLine(locNew.LOCATIONID);
}
As you can see I'm doing an insert into the LOCATION
table. Here I added a trigger:
create or replace
trigger TRG_LOCATION_INS
before insert on "HR"."LOCATIONS"
for each row
begin
if inserting then
select LOCATIONS_SEQ.nextval into :NEW."LOCATION_ID" from dual;
end if;
end;
Last step was setting StoreGeneratedPattern
in my model to Identity
(yes, I checked if it is written to the XML).
If I run the test-app, the record is created and it has got a valid new LocationID
. But in EF the new ID will not arrive.
Why isn't it recognizing the generated ID? If yes, what does that mean: DevArt Blog
EDIT: I tested it in different scenarios now:
- devArt EntityModel in Direct Mode
- devArt EntityModel with OracleClient
- ADO.NET EntityModel with OracleClient
The result is the same. No DSID
is returned on SaveChanged. As another result, if I write
ctx.Refresh(RefreshMode.ClientWins, log);
an InvalidOperationException will raise saying, that there is now entity with key '0' which is correct but not helpful :-(.