I am attempting to commit an update to my ASP.Net MVC project using GitHub integration in Microsoft Visual Studio 2017.
I am working on Code-First Migrations. After my previous successful commit, I performed the following commands on the Package Manager Console in Visual Studio:
PM> Enable-Migrations -ContextType ApplicationDbContext
PM> Add-Migration AccountNumberChanges
PM> Update-Database -Verbose
Once this was done, I tried perform a commit, but I was getting the following error:
Git failed with a fatal error.
error: open("MyProject/App_Data/aspnet-MyProject-
20171110110346.mdf"): Permission denied
fatal: Unable to process path MyProject/App_Data/aspnet-
MyProject-20171110110346.mdf
The above commands have added the .mdf file to the project's App_Data folder.
You shouldn't be committing mdf
files to git - they are data files for your database. git
is likely complaining because the file is in use and it needs read access to be able to send the data to the repository. The simplest solution is to remove it from git with git rm
. For example, at the command line:
git rm MyProject/App_Data/aspnet- MyProject-20171110110346.mdf