Alla fine ho risolto leggendo su un forum inglese
"My guess is that you actually have two seperate operations going on. Even
though the transaction is the same it's no longer in the same scope. A scope
has a much shorter lifespan. Your best bet is to actually try to do your
insert operation, or whatever is being performed in the ExecuteNonQuery, and
select the @@Identity value at the same time, otherwise they won't be
considered as being in the same scope"
Quindi seguendo tale consiglio , l operazione di esecuzione della query di inserimento, e quella di calcolo dell @@identity vanno fatte assieme,altrimenti è come se agissero su ambiti differenti,ed è per questo che mi restituiva continuamente 0 il last_id
spero a qualcuno possa tornare utile![]()