Tuesday, April 19, 2016

SQL Server Error: CREATE DATABASE failed. Some file names listed could not be created.

I recently installed Windows 10 under VMWare and added SQL Server Express to do some work with MVC5 using the default Entity Framework backend.

I kept getting this error:

Directory lookup for the file "c:\users\fincherm\documents\visual studio 2015\Projects\
Mvc5Demo\Mvc5Demo\App_Data\Jokes2.mdf"
failed with the operating system error 5(Access is denied.).
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.


It turns out the problem was the identity of the SQLExpress service, "NT Service\MSSQL$SQLExpress"  did not have write permissions in the file system to create a database.  Adding "write" permission to that identity fixed the problem and now my MVC app works with SQL Server.



No comments: