<commit_before>﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Whiteboard.DataAccess.Models;

namespace Whiteboard.DataAccess {
    public class DataBaseContext : DbContext, IDisposable {
        private static DataBaseContext context = new DataBaseContext();

        public DbSet<Profile> Profiles { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<RoleProfile> RoleProfiles { get; set; }
        public DbSet<Course> Courses { get; set; }
        public DbSet<SchoolStudent> SchoolStudents { get; set; }
        public DbSet<CourseClass> CourseClasses { get; set; }
        public DbSet<CourseStudent> CourseStudents { get; set; }
        public DbSet<CourseTeacher> CourseTeachers { get; set; }
        public DbSet<Whiteboard.DataAccess.Models.WhiteboardNote> Whiteboards { get; set; }

        // Request ... maybe should be done on a faster database, Redis ;)
        public static DataBaseContext Context {
            get { return context; }
        }

        private DataBaseContext() {

        }
        static DataBaseContext() {
            if (!context.Database.Exists()) {
                context.Database.CreateIfNotExists();
                context.Seed();
            }
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder) {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }<commit_msg>Fixed bug when database model changes, to delete it, create it and populate it with seed data<commit_after>﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Whiteboard.DataAccess.Models;

namespace Whiteboard.DataAccess {
    public class DataBaseContext : DbContext, IDisposable {
        private static DataBaseContext context = new DataBaseContext();

        public DbSet<Profile> Profiles { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<RoleProfile> RoleProfiles { get; set; }
        public DbSet<Course> Courses { get; set; }
        public DbSet<SchoolStudent> SchoolStudents { get; set; }
        public DbSet<CourseClass> CourseClasses { get; set; }
        public DbSet<CourseStudent> CourseStudents { get; set; }
        public DbSet<CourseTeacher> CourseTeachers { get; set; }
        public DbSet<Whiteboard.DataAccess.Models.WhiteboardNote> Whiteboards { get; set; }

        // Request ... maybe should be done on a faster database, Redis ;)
        public static DataBaseContext Context {
            get { return context; }
        }

        private DataBaseContext() {
        }
        static DataBaseContext() {
            if (!context.Database.Exists()) {
                context.Database.CreateIfNotExists();
                context.Seed();
            } else if (!context.Database.CompatibleWithModel(false)) {
                context.Database.Delete();
                context.Database.CreateIfNotExists();
                context.Seed();
            }
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder) {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
{'fraction_non_alphanumeric': 0.09048316251830162, 'fraction_numerical': 0.0, 'mean_word_length': 2.7333333333333334, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4925533', 'n_tokens_mistral': 922, 'n_tokens_neox': 865, 'n_words': 232}