65.9K
CodeProject 正在变化。 阅读更多。
Home

如何停止创建 aspnetdb.mdf 数据库

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0投票)

2013 年 10 月 11 日

CPOL
viewsIcon

13075

如果您使用 asp.net 成员资格提供程序,Visual Studio 在部署时保留此 SQL 数据库文件有时会很方便。

如果您使用 asp.net 成员资格提供程序,Visual Studio 在部署时保留此 SQL 数据库文件有时会很方便。但是,如果您想使用在 Web config 中指定的自己的生产数据库来存储成员资格表,并且不希望每次部署到生产环境时都创建此数据库,该怎么办? 这个问题有一个解决方案。 您只需在框架版本的 machine.config 中禁用它即可。 以下是如何关闭它。

  1. 使用 Windows 资源管理器浏览到 c:\windows\microsoft.net\framework\您的 .net 版本\config
  2. 在 Visual Studio 或记事本中打开 machine.config 文件
  3. 向下滚动,直到找到 connectionstrings 行
  4. 注释掉这一行
    1. <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
  5. 构建您的应用程序

删除 aspnetdb.mdf 文件并重新构建后,它就不应该再回来了。

© . All rights reserved.