Re: [Firebird-net-provider] EF - last inserted ID is 0

2017-08-29 Thread Mr. John via Firebird-net-provider
HiI've tried your second suggestion setting PK description to #PK_GEN# and not 
workingthanks

From: Jiří Činčura <j...@cincura.net>To: 
"firebird-net-provider@lists.sourceforge.net" 
<firebird-net-provider@lists.sourceforge.net>Sent: Tuesday, August 29, 2017, 
10:40:52 AM GMT+3Subject: Re: [Firebird-net-provider] EF - last inserted ID is 0
With DB First you can set it up in Properties the same way. Or you can use 
https://www.tabsoverspaces.com/230841-generated-primary-key-in-entity-framework-model-from-firebird/.

--
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/


On Tue, Aug 29, 2017, at 08:44, Mr. John via Firebird-net-provider wrote:
> Hi.I'm using Db first and as I found that is about code firstIf I'm wrong
> please someone give me some tips about using thatthanks.
>
> From: Jiří Činčura <j...@cincura.net>To:
> "firebird-net-provider@lists.sourceforge.net"
> <firebird-net-provider@lists.sourceforge.net>Sent: Monday, August 28,
> 2017, 2:48:44 PM GMT+3Subject: Re: [Firebird-net-provider] EF - last
> inserted ID is 0
> Why so complex. Just use
> https://msdn.microsoft.com/en-us/library/system.data.entity.modelconfiguration.configuration.primitivepropertyconfiguration.hasdatabasegeneratedoption(v=vs.113).aspx
> and that's it. You should consider you entities store agnostic, in fact.
>
> --
> Mgr. Jiří Činčura
> https://www.tabsoverspaces.com/
>
>
> --
> 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

--
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


Re: [Firebird-net-provider] EF - last inserted ID is 0

2017-08-29 Thread Jiří Činčura
With DB First you can set it up in Properties the same way. Or you can
use
https://www.tabsoverspaces.com/230841-generated-primary-key-in-entity-framework-model-from-firebird[1]/.
--
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/


On Tue, Aug 29, 2017, at 08:44, Mr. John via Firebird-net-provider wrote:> 
Hi.I'm using Db first and as I found that is about code firstIf
> I'm wrong> please someone give me some tips about using thatthanks.
>
> From: Jiří Činčura <j...@cincura.net>To:
> "firebird-net-provider@lists.sourceforge.net"
> <firebird-net-provider@lists.sourceforge.net>Sent: Monday, August 28,> 2017, 
> 2:48:44 PM GMT+3Subject: Re: [Firebird-net-provider] EF - last
> inserted ID is 0
> Why so complex. Just use
> https://msdn.microsoft.com/en-us/library/system.data.entity.modelconfiguration.configuration.primitivepropertyconfiguration.hasdatabasegeneratedoption(v=vs.113).aspx>
>  and that's it. You should consider you entities store agnostic,
> in fact.>
> --
> Mgr. Jiří Činčura
> https://www.tabsoverspaces.com/
>
>
> --
> > 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


Links:

  1. 
https://www.tabsoverspaces.com/230841-generated-primary-key-in-entity-framework-model-from-firebird/
--
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


Re: [Firebird-net-provider] EF - last inserted ID is 0

2017-08-29 Thread Mr. John via Firebird-net-provider
Hi.I'm using Db first and as I found that is about code firstIf I'm wrong 
please someone give me some tips about using thatthanks.

From: Jiří Činčura <j...@cincura.net>To: 
"firebird-net-provider@lists.sourceforge.net" 
<firebird-net-provider@lists.sourceforge.net>Sent: Monday, August 28, 2017, 
2:48:44 PM GMT+3Subject: Re: [Firebird-net-provider] EF - last inserted ID is 0
Why so complex. Just use
https://msdn.microsoft.com/en-us/library/system.data.entity.modelconfiguration.configuration.primitivepropertyconfiguration.hasdatabasegeneratedoption(v=vs.113).aspx
and that's it. You should consider you entities store agnostic, in fact.

-- 
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/


--
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


Re: [Firebird-net-provider] EF - last inserted ID is 0

2017-08-28 Thread Jiří Činčura
Why so complex. Just use
https://msdn.microsoft.com/en-us/library/system.data.entity.modelconfiguration.configuration.primitivepropertyconfiguration.hasdatabasegeneratedoption(v=vs.113).aspx
and that's it. You should consider you entities store agnostic, in fact.

-- 
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/


--
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


Re: [Firebird-net-provider] EF - last inserted ID is 0

2017-08-27 Thread Jiří Činčura
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
>BEGINIF ((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


Re: [Firebird-net-provider] EF - last inserted ID is 0

2017-08-26 Thread Mr. John via Firebird-net-provider
HiI'm using DbFirst,if I set 
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] attribute on the ID 
column after a model  refresh it will be lostthanks

From: Daniel Rail <dan...@accra.ca>To: 
"firebird-net-provider@lists.sourceforge.net" 
<firebird-net-provider@lists.sourceforge.net>Sent: Saturday, August 26, 2017, 
4:37:44 PM GMT+3Subject: Re: [Firebird-net-provider] EF - last inserted ID is 0
Hi,

At August 26, 2017, 1:38 AM, Mr. John via Firebird-net-provider wrote:


| 
 | Hi.
Thanks Paul for your answer
For my first code I've followed this: 
https://stackoverflow.com/questions/4068084/how-to-find-an-identity-of-the-last-inserted-row-in-entity-framework
and that seems not to apply to FB? |


That's how I do it.  Just make certain that you are using the 
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] attribute on the ID 
column in the myTableEnt entity.


-- 
Best regards,
 Daniel Rail
 Senior Software Developer
 ACCRA Solutions Inc. (www.accra.ca)
 ACCRA Med Software Inc. 
(www.filopto.com)--
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


Re: [Firebird-net-provider] EF - last inserted ID is 0

2017-08-25 Thread Mr. John via Firebird-net-provider
Hi.Thanks Paul for your answerFor my first code I've followed this: 
https://stackoverflow.com/questions/4068084/how-to-find-an-identity-of-the-last-inserted-row-in-entity-frameworkand
 that seems not to apply to FB?I so I can insert ID without trigger,directly 
from my code,something like this:
  myTableEnt   newRec= new myTableEnt()                {  ID= 
GetNextSequenceValue(ref db, "SELECT NEXT VALUE FOR GEN_MYTABLE_ID FROM 
RDB$DATABASE")                    NAME='MYNAME',                            
         };
...public long GetNextSequenceValue(ref myEnt ctx, string sql)        {         
    var rawQuery = ctx.Database.SqlQuery(sql);            var task = 
rawQuery.SingleAsync();            long nextVal = task.Result;            
return nextVal;        }

thanks


From: paul.mercea <paul.mer...@almexa.ro>To: For users and developers of the 
Firebird .NET providers <firebird-net-provider@lists.sourceforge.net>Cc: Mr. 
John <mr_joh...@yahoo.com>Sent: Friday, August 25, 2017, 11:35:11 PM 
GMT+3Subject: Re: [Firebird-net-provider] EF - last inserted ID is 0
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" 
<firebird-net-provider@lists.sourceforge.net> Date: 8/25/17 20:28 (GMT+02:00) 
To: "For Users and Developers of the Firebird .NET Providers" 
<firebird-net-provider@lists.sourceforge.net> Cc: "Mr. John" 
<mr_joh...@yahoo.com> Subject: [Firebird-net-provider] EF - last inserted ID is 
0 
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