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

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

问题描述

我目前正在建设中的Visual Studio 2010 Web应用程序项目和,直到最近,使用脚手架code为存储在数据库中的ASPNETDB.mdf文件成员,用户和角色等也没有必要。我一直在运行Visual Studio的Web服务器上的项目,IIS防爆preSS(从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.

不过,我现在需要把用户帐户,当我用脚手架code登录,我得到了一个服务器错误,指出:

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自动命名的数据库:\\用户\\用户\\文档\\ 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防爆preSS或IIS7.5 Web服务器会出现此错误。 Visual Studio的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中,然后通过该附加视觉工作室,但我无法登录到数据库。

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?

推荐答案

这是可能与你在没有访问该文件运行IIS的帐户的问题。

This is potentially an issue with the account you are running IIS under not having access to that file.

分配完全权限到该文件夹​​的网络服务帐户。

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天全站免登陆