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
Karolis Kundrotas aff6f8df82 Huge work
2021-10-25 22:00:01 +03:00

40 lines
1.3 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=saps;Password=;Database=saps_dev", new MariaDbServerVersion(new Version(10, 6, 3)));
}
}
public DbSet<IssueType> IssueTypes { get; set; }
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; }
public DbSet<Admin> Admins { get; set; }
}
}