简体   繁体   中英

ASP.NET identity is asking for local DB at App_Data

I have encountered the error asking for the App_Data local db , however I am not using the local db in my project and working with an online Db at the server.

在此输入图像描述

Here are the steps on how I have created my site:

1- New ASP.Net Web Application -> MVC – Individual User Authentication

2- Run the app, and register a new user (this is where I think the problem starts) – since at this point, it created a local db at App_Data

3- Create SQL Server 2017 database using SQL Server Management Studio and add my tables

4- Import the DB to the project as ADO.Net Entity Data Model -> EF Designer from database (with new connectionString)

5- Update the DefaultConnection to link to the new db

6- Run the project and register new user (Identity tables created at the new DB) I did not import the identity tables to the ADO.Net Entity Data Model

7- Upload the DB online at smarterasp.net

8- Update the connectionStrings to the new online DB

9- Continue working on the website…

10- Publish the website -> and it was asking for the App_Data local db's as attached !

There is no reference to any local db in the project. How can I fix this local DB thing without creating a new application.

    <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=SQL5041.site4now.net;
                                                Initial Catalog=DB_Name;
                                                User Id=admin;
                                                Password=***;" 
     providerName="System.Data.SqlClient" />
<add name="RP" connectionString="metadata=res://*/RPDatabaseModel.csdl|res://*/RPDatabaseModel.ssdl|res://*/RPDatabaseModel.msl;
                                    provider=System.Data.SqlClient;
                                    provider connection string=&quot;Data Source=SQL5041.site4now.net;Initial Catalog=DB_Name;User Id=admin;Password=***; MultipleActiveResultSets=true;&quot;" 
     providerName="System.Data.EntityClient" />

Try disabling your roleManager. In your web.config remove the entire roleManager section and replace it with:

<roleManager enabled="false" />

For some further info, in your machine.config you likely have a line like this:

<add name="AspNetSqlRoleProvider"
    connectionStringName="LocalSqlServer" applicationName="/" type="..."/>

And a connection string like this:

<add name="LocalSqlServer" 
    connectionString="...localdb..." 
    providerName="System.Data.SqlClient"/>

So leaving the role manager entries in there make Asp.Net start looking in this local db before your IdentityDbContext . Removing the entries means it tries to fine an entry and fails. So the only solution is to disable it completely.

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