Think the question is NOT about reading an error message, and NOT about how to enable identity_insert (you can see this from the 1st code snippet of the question itself). It is also NOT about if using identity_insert is a good, bad or risky thing.
The question was: "However when I run the application..."
Or: Why does it work once, but does not work a second time.
Answer: you have to enable identity_insert per connection.
Good practice: enable it only temporarily for a single insert statement.
use it only if you really need it.