How do I stop using ASPNETDB.MDF in LocalDB?

后端 未结 4 2030
小鲜肉
小鲜肉 2021-01-12 04:26

I implemented ASP.NET Identity and it automatically created ASPNETDB.MDF and aspnetdb_log.ldf in my App_Data folder. I already have the AspNet tables (i.e., AspNetRoles, Asp

4条回答
  •  星月不相逢
    2021-01-12 04:42

    I was getting exactly the same problem. I discovered that VS annoyingly pulls in config settings from machine.config, which lives outside of the project, in my case in...

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
    

    Identity 2.0 had used the following connection string inside machine.config...

    
        
    
    

    to set up a connection for...

           
            
                
            
        
    

    .. (which was also set in machine.config). If you haven't been using Membership then it's fine to do as Lord nick suggests (except just the clear/ will do the job) and simply do the following in web.config...

    
       
       
    

    However, if you, like me, previously had Membership running (https://msdn.microsoft.com/en-us/library/6e9y4s5t(v=vs.100).aspx), you will need to comment out or delete the following sections from machine.config...

    
    

    ... since all this stuff is no longer needed for AspNet Identity 2.

    I also had to add the following into in my web.config:

    
     
    
    

    ... as per this answer: Default Role Provider could not be found on IIS 7 running .NET 4

    I hope I've saved someone some time. This took me hours and hours to work out.

提交回复
热议问题