// Summary: // Initializes a new instance of the LongUrlContext class and configure given // Microsoft.EntityFrameworkCore.DbContextOptions to specify the connection string. private LongUrlContext GetContext() { var optionsBuilder = new DbContextOptionsBuilder <LongUrlContext>(); optionsBuilder.UseNpgsql(Configuration["ConnectionStrings:urlshortener"]); LongUrlContext context = new LongUrlContext(optionsBuilder.Options); return(context); }
public UrlShortenerController(IConfiguration config) { Configuration = config; context = GetContext(); }