diff --git a/ApplicationContext.cs b/ApplicationContext.cs new file mode 100644 index 0000000..0b5dcfa --- /dev/null +++ b/ApplicationContext.cs @@ -0,0 +1,12 @@ +using GerbilManager.Models; +using Microsoft.EntityFrameworkCore; + +public class ApplicationContext : DbContext +{ + public ApplicationContext(DbContextOptions options) + :base(options) + { + } + public DbSet Gerbils { get; set; } +} + diff --git a/GerbilManager.csproj b/GerbilManager.csproj index 7429eed..d6fce08 100644 --- a/GerbilManager.csproj +++ b/GerbilManager.csproj @@ -8,6 +8,8 @@ + + diff --git a/Program.cs b/Program.cs index 8ad3f5f..e5bf8b1 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,5 @@ using GerbilManager.Repositories; +using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); @@ -11,8 +12,11 @@ builder.Services.AddSwaggerGen(); builder.Services.AddSingleton(); +builder.Services.AddDbContext(opts => opts.UseSqlServer(Configuration.GetConnectionString("sqlConnection"))); + var app = builder.Build(); + // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/appsettings.Development.json b/appsettings.Development.json index ff66ba6..138e433 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -4,5 +4,8 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } + }, + "ConnectionStrings": { + "sqlConnection": "server=.; database=GerbilManagerDebug; Integrated Security=true" } } diff --git a/appsettings.json b/appsettings.json index 4d56694..77b42a0 100644 --- a/appsettings.json +++ b/appsettings.json @@ -5,5 +5,8 @@ "Microsoft.AspNetCore": "Warning" } }, + "ConnectionStrings": { + "sqlConnection": "server=.; database=GerbilManager; Integrated Security=true" + }, "AllowedHosts": "*" }