简体   繁体   中英

How to use SQL membership with transaction scope (without DTC)?

I'm trying to create a user using the SQL membership provider on SQL Express . When I use the TransactionScope it prompts to DTC with no apparent reason, how can I avoid it?

Here is my example code:

using (var ts = new TransactionScope())
{
    MembershipCreateStatus status;
    Membership.CreateUser(username, password, null, null, null, true, out status);

    var userProfile = ProfileBase.Create(username);

    userProfile.SetPropertyValue("Fullname", fullname);
    userProfile.Save();

    ts.Complete();
}

BTW, I checked in reflector and every membership SQL function always closes its connection.

如建议您可以实现此功能,无需交易在这里

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM