Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions WizardWorldApi/.idea/.idea.WizardWorldApi/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions WizardWorldApi/.idea/.idea.WizardWorldApi/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions WizardWorldApi/.idea/.idea.WizardWorldApi/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions WizardWorldApi/WizardWorld.Persistance/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Microsoft.EntityFrameworkCore;

namespace WizardWorld.Persistance {
public class ApplicationDbContext : DbContext {
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }

protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly);
}
}
}
8 changes: 0 additions & 8 deletions WizardWorldApi/WizardWorld.Persistance/Class1.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace WizardWorld.Persistance
{
public static class IServiceCollectionExtensions
{
public static void AddApplicationDbContext(this IServiceCollection serviceExtensions, string connectionString) {
serviceExtensions.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(connectionString));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.11" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion WizardWorldApi/WizardWorldApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WizardWorld.Persistance;

namespace WizardWorldApi
{
Expand All @@ -26,7 +27,7 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{

services.AddApplicationDbContext(Configuration.GetConnectionString("DefaultConnection"));
services.AddControllers();
services.AddSwaggerGen(c =>
{
Expand Down
4 changes: 4 additions & 0 deletions WizardWorldApi/WizardWorldApi/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "User ID=root;Password=MossPiglets;Host=localhost;Port=5432;Database=WizardWorld;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;"
}
}