My ASP.NET Core site just works fine. But when I delete the database file inside my user folder, it always tells me after restarting and creating the site, the database already exists. As workaround it helps changing the database name.
我的ASP.NET核心网站运行正常。但是当我删除我的用户文件夹中的数据库文件时,它总是在重新启动并创建站点后告诉我,数据库已经存在。作为解决方法,它有助于更改数据库名称。
But what do I have to delete to get rid of the database?
但是我要删除什么来摆脱数据库呢?
1 个解决方案
#1
1
Seems you are using SQL LocalDB. When you delete the mdf file you also need to delete the local instance of localDB.
似乎您正在使用SQL LocalDB。删除mdf文件时,还需要删除localDB的本地实例。
In package manager (or Visual Studio Debug Commandline) enter (PM>
is the Package manager prompt, don't enter this of course ;)).
在包管理器(或Visual Studio Debug Commandline)中输入(PM>是包管理器提示符,当然不要输入;))。
PM> SqlLocalDb.exe info
MSSQLLocalDB
v11.0
Now you know you have two local DBs, MSSQLLocalDB
and v11.0
.
现在你知道你有两个本地数据库,MSSQLLocalDB和v11.0。
First stop it
先阻止它
PM> SqlLocalDb.exe stop MSSQLLocalDB
Then delete it
然后删除它
PM> SqlLocalDb.exe delete MSSQLLocalDB
Finally start it again
最后重新开始
PM> SqlLocalDb.exe delete MSSQLLocalDB
Or created it before if necessary
或者在必要时创建它
PM> SqlLocalDb.exe create MSSQLLocalDB
#1
1
Seems you are using SQL LocalDB. When you delete the mdf file you also need to delete the local instance of localDB.
似乎您正在使用SQL LocalDB。删除mdf文件时,还需要删除localDB的本地实例。
In package manager (or Visual Studio Debug Commandline) enter (PM>
is the Package manager prompt, don't enter this of course ;)).
在包管理器(或Visual Studio Debug Commandline)中输入(PM>是包管理器提示符,当然不要输入;))。
PM> SqlLocalDb.exe info
MSSQLLocalDB
v11.0
Now you know you have two local DBs, MSSQLLocalDB
and v11.0
.
现在你知道你有两个本地数据库,MSSQLLocalDB和v11.0。
First stop it
先阻止它
PM> SqlLocalDb.exe stop MSSQLLocalDB
Then delete it
然后删除它
PM> SqlLocalDb.exe delete MSSQLLocalDB
Finally start it again
最后重新开始
PM> SqlLocalDb.exe delete MSSQLLocalDB
Or created it before if necessary
或者在必要时创建它
PM> SqlLocalDb.exe create MSSQLLocalDB