private SqlLocalDbInstance GetExistingInstance(SqlLocalDbProvider localDbProvider, string localDbInstanceName)
        {
            try
            {
                SqlLocalDbInstance existingInstance = localDbProvider.GetInstance(localDbInstanceName);

                IEnumerable <string> filePaths = GetPhysicalFilesForServer(existingInstance);

                bool isMissingFiles = filePaths.Any(path => !File.Exists(path));

                // If at least one file doesn't exist, delete them all.
                // We have found that the SqlLocalDbInstanceInfo.Exists property to not be reliable.
                if (isMissingFiles)
                {
                    LogAction("Existing LocalDb instance with name " + localDbInstanceName + " was found but some physical files were missing");
                    LogAction("Deleting instance and will attempt to recreate");

                    existingInstance.Stop();
                    SqlLocalDbApi.DeleteInstance(existingInstance.Name, deleteFiles: true);

                    foreach (string filePath in filePaths)
                    {
                        try
                        {
                            File.Delete(filePath);
                        }
                        catch (DirectoryNotFoundException) { }
                    }

                    return(null);
                }
                else
                {
                    LogAction("Found existing LocalDb instance with name " + localDbInstanceName + " and will use it");
                    LogAction("If you would like to delete this existing instance and let DbTestMonkey create a new instance run the following commands at a command line");
                    LogAction("   sqllocaldb stop " + localDbInstanceName);
                    LogAction("   sqllocaldb delete " + localDbInstanceName);

                    return(existingInstance);
                }
            }
            catch (InvalidOperationException)
            {
                LogAction("Existing LocalDb instance with name " + localDbInstanceName + " was not found");
            }

            return(null);
        }