I have an asp.net mvc project called Project1 that retrieves dataset from DB by CodeFirst approach. I have copied the project folder to a different location and renamed it as Project2. I would like to make changes to a Project2 without worrying about if my original project would get affected from these changes. What steps should I follow to do it safely without causing me further problems and time lose?
Asked
Active
Viewed 164 times
0
-
1If you copied it, why would project 2 have anything to do with project 1 – TheGeneral Feb 21 '19 at 08:44
-
3Possible duplicate of [Proper way to rename solution (and directories) in Visual Studio](https://stackoverflow.com/questions/2043618/proper-way-to-rename-solution-and-directories-in-visual-studio) – 41686d6564 stands w. Palestine Feb 21 '19 at 08:45
-
Wouldn't my project1 might get affected because they both have the same project and solution name? – Cavid Feb 21 '19 at 08:49
-
If you're worried about the effects of a global find and replace or rename refactor in Visual Studio affecting another project then in the case of find and replace scope it to the project, in the case of rename just temporarily remove the project you don't want touched from the solution? – Iain M Norman Feb 21 '19 at 08:52
1 Answers
0
I do this reasonably often with c# projects:
- copy the entire folder X, and rename the copy as Y. Y is at the same directory level as X (though I doubt it matters)
- perform a recursive rename of X -> Y on all subfiles and subfolders inside Y. My favourite tool for this is a utility called Renamer6.0 from a guy called Albert Bertilsson, but any rename tool that supports recursion will be fine
- perform a recursive Replace In Files for X->Y, using some capable code editor like Sublime, Notepad++, UltraEdit
That’s it, should be ready to go
Just remember that things like connection strings in config files are unlikely to be touched in terms of what database they connect to, so don’t go and wreck project1’s database by launching an altered project2, without double checking config entries in project2

Caius Jard
- 72,509
- 5
- 49
- 80
-
Blindly replacing text in code files is very very bad advice. Check the answers in the duplicate question. – 41686d6564 stands w. Palestine Feb 21 '19 at 08:58
-
What does he lose if it doesn't work out? It's a copy of a project, the process above takes about 40 seconds and if it doesn't work out, just delete it. Regardless of your opinion, I've used the method described many times in the past to generate a new project based off of an old one, with no ill affects – Caius Jard Feb 21 '19 at 20:41