In SQL Server, ID is a not null integer, and an identity.
When I run the following code, I get an InvalidCastException on the last line:
SqlCommand
It's probably returning a boxed instance of a different numeric type, such as long. A boxed long cannot be converted to int.
long
You can call GetType() on the return value to see what type it really is.
GetType()