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

亡梦爱人 提交于 2019-12-01 05:43:49

问题


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?


回答1:


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.




回答2:


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

  • 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


来源:https://stackoverflow.com/questions/25129432/cant-check-in-mdf-ldf-in-app-data-into-tfs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!