This repository has been archived on 2025-08-13. You can view files and clone it, but cannot push or open issues or pull requests.
Files
KTUSA-PS/KTUSAPS.Data/SAPSDataContext.cs
Nadegamra a3b4bb2e30 Mostly backend models stuff
Changed some models, did some work on database, created a class diagram.
2021-09-08 20:20:32 +03:00

37 lines
1.2 KiB
C#

using KTUSAPS.Data.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KTUSAPS.Data
{
public class SAPSDataContext : DbContext
{
public SAPSDataContext() : base() { }
public SAPSDataContext(DbContextOptions options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Vote>()
.HasKey(v => new { v.UserId, v.ProblemId });
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseMySql("Server=localhost;User=samokdev;Password=;Database=samok_dev", new MariaDbServerVersion(new Version(10, 6, 3)));
}
}
public DbSet<Issue> Issues { get; set; }
public DbSet<PublishedFeedback> PublishedFeedbacks { get; set; }
public DbSet<PublishedProblem> PublishedProblems { get; set; }
public DbSet<Solution> Solutions { get; set; }
public DbSet<Vote> Votes { get; set; }
}
}