Проблема заключается в пути к каталогу файл .mdf. Я использовал Scaffold-db, чтобы все настроить, и в настоящее время путь указан к папке моих пользователей (где существует мой проект).
Я пробовал:
Код: Выделить всё
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\Database\DATABASE.mdf");
Код: Выделить всё
// Get the Downloads folder for the current user
string downloadsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
// Construct the full path to the database
string databasePath = Path.Combine(downloadsPath, "DATABASE.mdf");
// Connection string using the dynamic path
string connectionString = $@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={databasePath};Integrated Security=True";
Подробнее здесь: https://stackoverflow.com/questions/792 ... per-client