Your myTableEnt should have Id marked as DatabaseGen…Options.Identity.
Then it's fetched back automatically.
--
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/
On Fri, Aug 25, 2017, at 19:28, Mr. John via Firebird-net-provider wrote:>
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:
> CREATE OR ALTER TRIGGER TRIG_MYTABLE_BI FOR MYTABLE
> 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, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Firebird-net-provider mailing list
> Firebird-net-provider@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider