[ADO.NET error]: CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file HelloWorld.mdf failed

StackOverflow https://stackoverflow.com/questions/14872

Question

CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file C:\Documents and Settings\..\App_Data\HelloWorld.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I've found these links:

Was it helpful?

Solution

Generally the user that you are using to run the SQL Server service will not have access to your personal user folders, that is why you're getting the error. You either need to change the credentials used for the service, or move the database to another folder, which did the trick in your case.

OTHER TIPS

For me helped a lot to set this tag under system.web tag on the web.config file:

<system.web>
    <identity impersonate="true" userName="admin_user" password="admin_password" />
...

Hope this can help somebody

I was stuck on this today with compound issue in mvc3 and entity framework code first.

My SqlExpress install is messed up (permissions issues) so I switched to SqlCE.

My ConnectionString.Name attribute didn't match my "ProjectNameContext" class name.

When the connection string isn't found, it uses default conventions. Default conventions means my SqlExpress service with a database name like "ProjectNameContext". The permissions are messed up on that so I got a permissions error on SqlExpress when I thought I was using SqlSE

I was also experiencing the same Problem, finally i find Solution- SOLUTION -- Is simple Move or Cut your database from the App_Data folder to any where (e.g., Desktop) then Move or Cut back DataBase to App_Data folder. That is it..........

Hope it work!

Yes, a previous attachment wasn't unattached properly, or it was attached manually. Go in to Management Studio connect to the database, and disconnect the long database name that looks like a file path. Then try again it should work.

My friend fixed it by just using another directory, namely C:\TEMP. I think it was just a permissions thing.

for some guys like me,add "User Instance=true" to your connection string

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top