asp.net-mvctfsasp.net-mvc-5azure-devopsapp-data

Can't check in .mdf/.ldf in App_Data into TFS


I am working with ASP.NET C# MVC 5.

.mdf/.ldf files in App_Data do not appear on Pending Changes in team explorer. Therefore I can't check them into TFS(visual studio online). I've tried recreating the project a few times and none worked. What might be the cause for this?


Solution

  • Go to Team Explorer and locate Excluded Changes and you should find it excluded. Right click the App_Data folder and include it.

    But you might want to reconsider including the database files. As you're developing and testing, every little database interaction will trigger a change and most of those are trivial. Also, if someone else is working on this project, they may not want your database file to overwrite theirs when they Get Latest Version.

    If you're using Entity Framework Code-First, the database is automatically generated when you build the project I believe, otherwise you just run the Update-Database command to do it. This lets everyone collaborating have their own local database file to work with. You can also utilize migrations to make updates to the database structure. If you want the database to be generated with pre-populated data, you should utilize the Seed method.