Я занимаюсь обновлением проекта .NET 4.7.1 до .NET 8.
Этот проект использует EF 6, и ему нужны строки подключения из файла конфигурации.
К моему удивлению, соединение, которое я запрашиваю, отсутствует в
Код: Выделить всё
ConnectStringSettingsCollection. Более того, эта коллекция содержит только одно соединение — соединение LocalDb по умолчанию:
data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
Код: Выделить всё
using System.Configuration;
string _endpoint = System.Configuration.ConfigurationManager.AppSettings["endpoint"]!;
string _connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["sqlServer"]!.ConnectionString;
Console.WriteLine($"Endpoint: {_endpoint}");
Console.WriteLine($"Connection String: {_connectionString}");
Код: Выделить всё
Exe
net8.0
enable
enable
Код: Выделить всё
As a side note, I am working with .NET Core on a MacBook, not on a Windows Machine. But I have tested the code that does not work on a windows machine and the problem remains the same.
Источник: https://stackoverflow.com/questions/781 ... ldb-asp-ne