Add db context
All checks were successful
Game Ideas build for PR / build_blazor_app (pull_request) Successful in 36s
All checks were successful
Game Ideas build for PR / build_blazor_app (pull_request) Successful in 36s
This commit is contained in:
21
src/GameIdeas/GameIdeas.Shared/Model/Game.cs
Normal file
21
src/GameIdeas/GameIdeas.Shared/Model/Game.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace GameIdeas.Shared.Model;
|
||||
|
||||
public partial class Game
|
||||
{
|
||||
public Game()
|
||||
{
|
||||
GamePlatforms = new HashSet<GamePlatform>();
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; } = null!;
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? ModificationDate { get; set; }
|
||||
public double? StorageSpace { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public int? Interest { get; set; }
|
||||
|
||||
public virtual ICollection<GamePlatform> GamePlatforms { get; set; }
|
||||
}
|
||||
|
||||
10
src/GameIdeas/GameIdeas.Shared/Model/GamePlatform.cs
Normal file
10
src/GameIdeas/GameIdeas.Shared/Model/GamePlatform.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace GameIdeas.Shared.Model;
|
||||
|
||||
public partial class GamePlatform
|
||||
{
|
||||
public int GameId { get; set; }
|
||||
public int PlatformId { get; set; }
|
||||
|
||||
public virtual Game Game { get; set; } = null!;
|
||||
public virtual Platform Platform { get; set; } = null!;
|
||||
}
|
||||
8
src/GameIdeas/GameIdeas.Shared/Model/Platform.cs
Normal file
8
src/GameIdeas/GameIdeas.Shared/Model/Platform.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace GameIdeas.Shared.Model;
|
||||
|
||||
public partial class Platform
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Libelle { get; set; } = null!;
|
||||
public string? Url { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using GameIdeas.Shared.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GameIdeas.WebAPI.Context;
|
||||
|
||||
public class GameIdeasContext : DbContext
|
||||
{
|
||||
public GameIdeasContext(DbContextOptions<GameIdeasContext> option)
|
||||
: base(option)
|
||||
{ }
|
||||
|
||||
public virtual DbSet<Game> Games { get; set; } = null!;
|
||||
public virtual DbSet<Platform> Platforms { get; set; } = null!;
|
||||
public virtual DbSet<GamePlatform> GamePlatforms { get; set; } = null!;
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql(@"Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
@@ -12,10 +12,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\GameIdeas.Resources\GameIdeas.Resources.csproj" />
|
||||
<ProjectReference Include="..\..\GameIdeas.Shared\GameIdeas.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user