The trigger from you database has nothing to do with your c# code.You can use a 
stored procedure to insert data and returning latest id (also you can read 
current sequence value but you can have wrong value if other inserts happening).

Sent from my Samsung Galaxy smartphone.
-------- Original message --------From: "Mr. John via Firebird-net-provider" 
<> Date: 8/25/17  20:28  (GMT+02:00) 
To: "For Users and Developers of the Firebird .NET Providers" 
<> Cc: "Mr. John" 
<> Subject: [Firebird-net-provider] EF - last inserted ID is 
HiI'm using FB 2.5,EF Firebird 5.9.1,Asp MVC 5 with VS 2017
 on a table I have a trigger to generate ID:
ACTIVE BEFORE INSERT POSITION 0                      AS                      
BEGIN                        IF ((NEW.ID IS NULL) OR (NEW.ID=0)) THEN           
              NEW.ID=NEXT VALUE FOR GEN_MYTABLE_ID;                      END

in my code I insert data like this:
           myTableEnt   newRec= new myTableEnt()                {               
     NAME='MYNAME',                    ....                 };

                db.myTableEnt.Add(newRec);                db.SaveChanges();     
           return ToJson(new { msg = newRec.ID.ToString() });
 newRec.ID is returned always 0,but in database value is generatedwhat I've 
done wrongthanks
Check out the vibrant tech community on one of the world's most
engaging tech sites,!
Firebird-net-provider mailing list

Reply via email to