Can anyone help? I have been using the entity framework and its going well 🙂
But i have just added a new record using an entity class like so
this._entities.AddToUsers(user);
The AddTo is created automatically .. and users is my table… All great but how do i return the identity column?
The sounds like just what i need instead of calling a stored procedure, I did have a stored procedure before –
I suppose i can continue using the stored procedure but this means i have to convert my User entity class to Sql parameters.
I am using EFExtensions.
And once added do i need to call SaveChanges or something?
Any ideas ??
Thanks
Yes, AddToUsers only adds your object into the in-memory entity context – it isn’t saved on disk just yet, and thus your new identity value hasn’t been assigned yet.
Only calling .SaveChanges() will actually write the changes to the database – and then and only then, the identity value (if your field is of type INT IDENTITY) will get generated.
Marc