밥상을 만들 수있는 적절한 방법SimpleMembership - 트랜잭션을
Envrionment : ASP.NET MVC 4, 면도기
나는 내 웹 응용 프로그램 SimpleMembership 제공자를 사용하고 있습니다. 사용자가 등록을 요청하면 WebSecurity.CreateUserAndAccount를 호출하고 다른 테이블도 업데이트해야합니다. 전체 작업은 트랜잭션이어야합니다. 여기에 내가 생각하는 바가있다 :
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();
}
}
나는 이것이 작동해야한다고 느낀다. 그러나 더 좋은 방법이 있는지에 대한 귀하의 전문적인 의견을 듣고 싶습니다.
도움을 주셔서 감사합니다.
감사합니다,
피터 당신이 그것을 배포하는 곳이 있다면