A
A
andoral2019-03-15 16:06:04
ASP.NET
andoral, 2019-03-15 16:06:04

"Permission denied" when trying to create a database file (Code First) in the App_Data directory. How to fix?

An account with administrator rights.
I did not change the rights to the App_Data folder.
The project itself is in "My Documents".
SQL Server Express 2017.

<add name="DrinkContext" connectionString="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|\Drinks.mdf;Integrated Security=True"
         providerName="System.Data.SqlClient"/>

System.Data.SqlClient.SqlException: 'Directory lookup for file 'C:\Users\sumo\Documents\Visual Studio 2017\Projects\SodaDispencer2\SodaDispenser2\App_Data\Drinks.mdf' failed, causing operating system error 5(Denied access.).
CREATE DATABASE operation failed. Some of the listed filenames were not created. Check related errors.'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
John_Nash, 2019-03-15
@John_Nash

Run studio as administrator

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question