<commit_before>﻿// ----------------------------------------------------------------------------
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
// ----------------------------------------------------------------------------
namespace Yaaf.Database

open Microsoft.AspNet.Identity.EntityFramework
open System
open System.Collections.Generic
open System.Data.Entity
open System.Data.Entity.Core.Objects
open System.Data.Entity.Infrastructure
open System.Linq
open System.Text
open System.Threading
open System.Threading.Tasks
open Yaaf.Helper

type AbstractApplicationDbContext(nameOrConnectionString) as x =
    inherit DbContext(nameOrConnectionString : string)
           
    static do
        if (String.IsNullOrWhiteSpace (AppDomain.CurrentDomain.GetData ("DataDirectory") :?> string)) then
            System.AppDomain.CurrentDomain.SetData (
                "DataDirectory",
                System.AppDomain.CurrentDomain.BaseDirectory)


    abstract Init : unit -> unit
    default x.Init () = ()
    
    member x.DoInit () =
        x.Init ()
        x.Database.Initialize (false)
        
    member x.MySaveChanges () =<commit_msg>add init code of AbstractApplicationDbContext as well.<commit_after>﻿// ----------------------------------------------------------------------------
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
// ----------------------------------------------------------------------------
namespace Yaaf.Database

open Microsoft.AspNet.Identity.EntityFramework
open System
open System.Collections.Generic
open System.Data.Entity
open System.Data.Entity.Core.Objects
open System.Data.Entity.Infrastructure
open System.Linq
open System.Text
open System.Threading
open System.Threading.Tasks
open Yaaf.Helper

type AbstractApplicationDbContext(nameOrConnectionString, ?doInit) as x =
    inherit DbContext(nameOrConnectionString : string)
    let doInit = defaultArg doInit true
           
    static do
        if (String.IsNullOrWhiteSpace (AppDomain.CurrentDomain.GetData ("DataDirectory") :?> string)) then
            System.AppDomain.CurrentDomain.SetData (
                "DataDirectory",
                System.AppDomain.CurrentDomain.BaseDirectory)
    do if doInit then x.DoInit()


    abstract Init : unit -> unit
    default x.Init () = ()
    
    member x.DoInit () =
        x.Init ()
        x.Database.Initialize (false)
        
    member x.MySaveChanges () =
{'fraction_non_alphanumeric': 0.19330999611046285, 'fraction_numerical': 0.0, 'mean_word_length': 1.9872241579558654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6885920', 'n_tokens_mistral': 603, 'n_tokens_neox': 604, 'n_words': 171}