<commit_before>﻿
********************************************
Step 1: Drop batch tables
********************************************
Remove Hangfire tables and sequences before scaffolding the db

********************************************
Step 2: Generate / Update Model:
********************************************
Scaffold-DbContext "Host=localhost;Username=postgres;Password=<PASSWORD>;Database=hets;Port=9010" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Model -Force -Project "HetsData" -Verbose -Context "DbAppContext" -Schema "public"

********************************************
Step 3: Update Context
********************************************
After generating the model need to update the DbAppContext class to manage the connection string.

Add new constructor:

private readonly string _connectionString;

public DbAppContext(string connectionString)
{
    _connectionString = connectionString;
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    if (!optionsBuilder.IsConfigured)
    {
        optionsBuilder.UseNpgsql(_connectionString);
    }
}

********************************************
Step 4: Fix Collection Attributes:
********************************************
Tag all collections with the following (replace Name as required):
[JsonProperty("Id")]
[JsonProperty("Name")]


Collections (e.g.):
[JsonProperty("Attachments")]
public ICollection<HetAttachment> HetAttachment { get; set; }

[JsonProperty("EquipmentAttachments")]
public ICollection<HetEquipmentAttachment> HetEquipmentAttachment { get; set; }

[JsonProperty("History")]
public ICollection<HetHistory> HetHistory { get; set; }

********************************************
Step 5: Fix Invalid Collections (created by FK):
********************************************
Tag collections with the following:

[JsonIgnore]


[JsonIgnore]public string AppCreateUserDirectory { get; set; }
[JsonIgnore]public string AppCreateUserGuid { get; set; }
[JsonIgnore]public string AppCreateUserid { get; set; }
[JsonIgnore]public DateTime AppCreateTimestamp { get; set; }
[JsonIgnore]public string AppLastUpdateUserDirectory { get; set; }
[JsonIgnore]public string AppLastUpdateUserGuid { get; set; }
[JsonIgnore]public string AppLastUpdateUserid { get; set; }
[JsonIgnore]public DateTime AppLastUpdateTimestamp { get; set; }
[JsonIgnore]public string DbCreateUserId { get; set; }
[JsonIgnore]public DateTime DbCreateTimestamp { get; set; }
[JsonIgnore]public DateTime DbLastUpdateTimestamp { get; set; }
[JsonIgnore]public string DbLastUpdateUserId { get; set; }
<commit_msg>Updated scaffolding instructions<commit_after>﻿********************************************
Step 1: Generate / Update Model:
********************************************
Scaffold-DbContext "Host=localhost;Username=postgres;Password=<PASSWORD>;Database=hets;Port=9010" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Model -Force -Project "HetsData" -Verbose -Context "DbAppContext" -Schema "public"

********************************************
Step 2: Update Context
********************************************
Remove the OnConfiguring override method.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    if (!optionsBuilder.IsConfigured)
    {
        optionsBuilder.UseSqlServer("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=aspnet-crt");
    }
}
{'fraction_non_alphanumeric': 0.25819793205317576, 'fraction_numerical': 0.004431314623338257, 'mean_word_length': 8.126684636118599, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '4597792', 'n_tokens_mistral': 851, 'n_tokens_neox': 829, 'n_words': 223}