37 lines
1.2 KiB
C#
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; }
|
|
|
|
}
|
|
}
|