oliverbooth.dev/OliverBooth/Data/WebContext.cs
Oliver Booth bd999f0ed8
feat: add preliminary /blog routes
This change also introduces toml file config
2023-08-06 15:57:44 +01:00

29 lines
798 B
C#

using Microsoft.EntityFrameworkCore;
namespace OliverBooth.Data;
/// <summary>
/// Represents a session with the web database.
/// </summary>
public sealed class WebContext : DbContext
{
private readonly IConfiguration _configuration;
public WebContext(IConfiguration configuration)
{
_configuration = configuration;
}
/// <inheritdoc />
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string connectionString = _configuration.GetConnectionString("Web") ?? string.Empty;
ServerVersion serverVersion = ServerVersion.AutoDetect(connectionString);
optionsBuilder.UseMySql(connectionString, serverVersion);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}