As I can see, I cannot access from this method IConfiguration injected object. Also, there's no way to, as I can see, access HttpContext and get in from there. Is there any simple way how can I get the connections string stored in appsettings.json?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Projekt.Models;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
namespace Project.DAL
{
public class UserContext : DbContext
{
public DbSet<User> Users {get;set;}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string connection_string = ""; //connection string from appsettings.json
optionsBuilder.UseSqlServer(connection_string);
}
public class User {
public string login{ get; set; }
public string password { get; set; }
}
}
}