尝试为.mdf文件附加自动命名数据库失败 [英] Attempt to attach an auto-named database for .mdf file failed

查看:684
本文介绍了尝试为.mdf文件附加自动命名数据库失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在Visual Studio 2010中构建Web应用程序项目,直到最近,还没有必要使用存储在ASPNETDB.mdf数据库文件中的成员身份,用户和角色等的脚手架代码。我已经在Visual Studio Web服务器上运行该项目,IIS Express(从Visual studio)和IIS7.5没有问题。

I am currently building a Web Application Project in Visual Studio 2010 and, until recently, have not needed to use the scaffolded code for Memberships, Users and Roles etc that are stored in the ASPNETDB.mdf database file. I have been running the project on the Visual Studio Web Server, IIS Express (from Visual studio) and also IIS7.5 without a problem.

但是,现在我需要包含用户帐户,当我使用脚本代码登录时,我得到一个服务器错误,说明:

However, I now need to incorporate User accounts and when I use the scaffolded code to log in, I get a server error stating:


文件C的命名数据库:\Users\User\Documents\COMP6059\PomumV2\PomumV2\App_Data\aspnetdb.mdf
失败。存在具有相同名称的数据库,或
指定的文件无法打开或位于UNC共享上。

An attempt to attach an auto-named database for file C:\Users\User\Documents\COMP6059\PomumV2\PomumV2\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

此错误仅在使用IIS Express或IIS7.5 Web服务器时发生。

This error only occurs when I am using either the IIS Express or IIS7.5 web server. The Visual Studio Web Server works fine.

我遵循了 http://support.microsoft.com/?kbid=2002980 无效。

以下是我的数据库连接字符串:

Below is my connection string for the database:

<add name="ApplicationServices"
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
     providerName="System.Data.SqlClient" />

错误发生在 AccountController.cs 文件(自动生成)

The error occurs on the following line of the AccountController.cs file (which is auto-generated)

...  if (Membership.ValidateUser(model.UserName, model.Password)) { ...

我在某处读取了数据库SQL Server Management Studio,然后通过它连接visual studio,但我无法登录数据库。

I did read somewhere that I might need to move the database into SQL Server Management Studio and then attach visual studio via that, but I was unable to log into the database.

我想要能够在IIS7.5上运行。有人对如何解决这个问题有任何想法吗?

I want this to be able to run on IIS7.5. Does anyone have any ideas on how to solve this issue?

推荐答案

这可能是一个问题,

您为网络服务帐户指定了该文件夹的完整权限。

Assign full permissions to that folder for the Network Service account.

可以暂时尝试每个人,看看是否解决了问题,并从那里向后工作。

You can temporarily try 'everyone' and see if it resolves the issue, and work backwards from there.

还要确保它不被其他web服务器使用sysinternals可以帮助显示)

Also ensure its not in use by the other web server (process explorer/sysinternals can help show you that)

这篇关于尝试为.mdf文件附加自动命名数据库失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆