How do I stop using ASPNETDB.MDF in LocalDB?

后端 未结 4 2031
小鲜肉
小鲜肉 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:33

    It seems you have something like in your web.config

    
    

    In your AccountModels.cs file, you have:

    public class UsersContext : DbContext
    {
        public UsersContext()
            : base("DefaultConnectionForLocalDb")
        {
        }
    }
    

    However it should be this way:

    
    
    public class UsersContext : DbContext
    {
        public UsersContext()
            : base("DefaultConnectionForSQLEXPRESS")
        {
        }
    }
    

    Then you can remove safely DefaultConnectionForLocalDb entry from your web.config and ASPNETDB.MDF from to App_Data.

提交回复
热议问题