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

1.9k Views Asked by At

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?

2

There are 2 best solutions below

2
On BEST ANSWER

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.

0
On

This is a general question. As already answered by 'Ty Morrow' in above comment there is an initial Seed Method in Entity Framework which ensures that all values are inserted. However there are many scenarios that you also need to work with the latest added / removed DB entries not present in the seed method.

Please perform the following steps to ensure that your data directory file is included in the source control.

  • Click App_Data folder and on encircled toolbar click on Show All Files as shown below in the snapshot

See the Encircled and click on **Show All Files**

  • Right Click on your MDF (Data Source) File and click on Include in Project
  • Right Click again on your MDF File and click on Include in Source Control
  • Simply Check in the file by Right Clicking on root project folder link and file show be now part of Source Control