Matthias Müller
Matthias Müller

Reputation: 3473

TFS: Delete and re-create Files, TFS doesn't see the Add

When I delete and re-add a file in Visual Studio, which is under TFS-SourceControl, if I check in, the TFS only detects the Delete, but not the add. Since we trigger a "Compile"-Check after each checkin, this always triggers an error, since the newly added File is not found, so we have to check-in twice.

Is there a possibility to tell the TFS to mark the deleted/added file not as deleted, but just as changed?

Upvotes: 2

Views: 2114

Answers (3)

Gotham Llianen
Gotham Llianen

Reputation: 604

For me the issue was with re-added Table in Entity-Framework.

In EF DB-First when changing column definition in DB, EF does not detect any change or when removing a column. (ex: when making a column nullable)

This is only fixed by removing and re-adding the table in the edmx.

TFS only detects the remove, not the add of the table's .cs file. Then TFS doesnt let you revert the delete because "file already exists"

This can be fixed by opening the local CS file in a text editor to save the current generated code (1. save the local cs class), then delete the file (to match the tfs state) so that you can revert the delete in the pending changes (2. delete the physical cs file) (3. revert delete in the pending changes window), then manually replace the reverted cs file code with the one saved in the text editor (4. manually update the cs class with the code saved in '1'). Review and Commit your changes.

Upvotes: 1

Alistair Mackay
Alistair Mackay

Reputation: 149

What exactly are you trying to do? If you delete the file, TFS will set the state of the file in source control to "delete pending". It isn't possible to then change the state of the file again to something else without either first checking in the pending change or undoing it. Delete and Add are incompatible pending changes on the same object.

Surely if you are deleting then re-adding a file you are in effect making an edit change, which would be properly tracked in the history. Why not check the file out for edit and assuming the new content is radically different from the original, overwrite the checked out file with the new content and then check it back in.

Upvotes: 2

Yaser Jaradeh
Yaser Jaradeh

Reputation: 322

select the files that don't have the blue lock icon next to them and open the context menu and add them to source control (include in project) then Pending changes will see them

Upvotes: 1

Related Questions