Folks,
Envrionment: ASP.NET MVC 4, Razor
I am using SimpleMembership provider for my web application. When the user requests for registration, I need to call WebSecurity.CreateUserAndAccount and also update some other tables. The whole operation has to be transactional. Here is what I am thinking:
using (UsersContext ctx = new UsersContext()) {
using (TransactionScope scope = new TransactionScope()) {
// The following call creates its own context but will call ctx.SaveChanges() internally
WebSecurity.CreateUserAndAccount(...);
// update some other tables using ctx
...
ctx.SaveChanges();
scope.complete();
}
}
I have a feeling this should work. However, I would like to get your expert opinion on whether there is a better way.
Thank you in advance for your help.
Regards,
Peter