I have a localdatabase "office.mdf" I want my application to be able to export the database and import it again I tried to achieve that using backup query
DB.ExecuteNonQuery(@"BACKUP DATABASE [" + Directory.GetCurrentDirectory() + @"\office.mdf] TO DISK = N'" + distination + "'");
and restore query
DB.ExecuteNonQuery(@"USE [master]; RESTORE DATABASE [" + Directory.GetCurrentDirectory() + @"\office.mdf] " +
@"FROM DISK = N'" + source + "' WITH FILE = 1 , NOUNLOAD, REPLACE, STATS = 10 , NORECOVERY , " +
@" MOVE 'office_log' TO '" + Directory.GetCurrentDirectory() + @"\office_log.ldf'" +
@" MOVE 'office' TO '" + Directory.GetCurrentDirectory() + @"\office.mdf'");
I build my project and I run it on another device then I export the database , I imported the database successfully but after that I couldn't connect to the database anymore and I got message that says
Login failed for user "myuser"
so the first thing how can I solve this problem and after that what is the best approach to export the database and import it back from another device how can I merge the existing database with the exported when (So I won't loose the existing data)