Haven't worked in .net core before and I am having some issues with the connection string. I am trying to get the connection string in my controller like so
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["DefaultConnection"].ToString());
but I am getting an 'Object reference not set to an instance of an object.' in my controller. This is what my appsettings.json looks like
"ConnectionStrings": {
"DefaultConnection": "Server=(server)\\\\mssqllocaldb;Database=dbName;User ID=user;Password=123123"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"