locked
Sequence current value not returning by using entity framework 6.2.0 and EntityFramework6.Npgsql 3.2.0 with npgsql 4.0.2.0 RRS feed

  • Question

  • Dear all,

    By using npgsql 2.1.3 with npgsql.entityframework 2.1.3, I found  following log after insertion...

    INSERT INTO "public"."user_details"("user_name","user_address","consumption_day") VALUES (E'vmm',E'def',TIMESTAMP '2018-08-10T00:00:00.0000000+05:30');

    SELECT currval(pg_get_serial_sequence('"public"."user_details"', 'user_id')) AS "user_id"

    Now when I used the npgsql 4.0.2.0 and EntityFramework6.Npgsql 3.2.0, I found following log after insertion...

    INSERT INTO "public"."user_details"("user_name","user_address","consumption_day") VALUES (E'vmm',E'def',TIMESTAMP '2018-08-10T00:00:00.0000000+05:30');

    RERURNING "user_id"

    I need to retrieve sequence current value always with npgsql 4.0.2.0 and EntityFramework6.Npgsql 3.2.0.

    Please suggest for any possible solution

    Thanks in advance,

    Sawan


    Tuesday, August 14, 2018 7:21 AM

All replies

  • If EF is being used correctly where the ID is some kind of integer using an auto incremented number for the primary-key, then EF will populate the key back to the primary-key-property of the object when the object has been successfully inserted into the database. You can get the primary-key right after the insert of the object by addressing the object in code.
    Tuesday, August 14, 2018 10:56 AM