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

后端 未结 2 1085
南笙
南笙 2021-01-14 03:58

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 stud

相关标签:
2条回答
  • 2021-01-14 04:34

    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 讨论(0)
  • 2021-01-14 04:35

    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
    0 讨论(0)
提交回复
热议问题