LocalDB 파일로 개발하는 도중 만날 수 있는 예외 메시지입니다.
제가 만난 경우는 메인프로젝트의 App_Data 폴더에 xxxx.mdf local DB가 있고 유닛테스트 프로젝트에서는 참조해서 쓰는 경우에 발생했습니다.
메인 프로젝트의 Web.config 의 Connection String 섹션명과 유닛테스트 프로젝트의 App.config 의 Connection String 섹션 명이 같게 설정되어 있습니다.
관련 내용 검색은
1. localDB data source
2. UNC share 관련
http://forums.asp.net/t/1956317.aspx?A+database+with+the+same+name+exists+or+specified+file+cannot+be+opened+or+it+is+located+on+UNC+share+
포스트를 참고했으나 해결책이 되진 못했습니다.
해결책은 연결 방식의 문제가 아니었고 localDb를 참조하는 폴더 규칙이었습니다.
예로 Web.config의 LocalDB 참조 경로는
data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\xxxxx.mdf;
이고 유닛 테스트 프로젝트의 App.config 의 LocalDB 참조 경로는
data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\ xxxxx.mdf;
App.config에는
Server Explorer > Data Connections > 실제 연결된 접속 > Properties > Misc > Primary File Path 의 경로를 붙여 넣어 줍니다.