Answer the question
In order to leave comments, you need to log in
The variable is not initialized. Why?
Variable not initialized `connectionString`
and throws an exception
`System.ArgumentNullException: "Значение не может быть неопределенным.
Имя параметра: connectionString"
var builder = new ConfigurationBuilder();
builder.SetBasePath(Directory.GetCurrentDirectory());
builder.AddJsonFile("appsetings.json");
var config = builder.Build();
var optionsBuilder = new DbContextOptionsBuilder<ApplicationContext>();
string connectionString = config.GetConnectionString("DefaultConnection");
var options = optionsBuilder
.UseSqlServer(connectionString)
.Options;
{
"ConnectionStrings ": {
"DefaultConnection": "Data Source=DESKTOP-00IRUOM;Initial Catalog=Practice;Integrated Security=True;Pooling=False;"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question