<commit_before>﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace core.Extensions.Data
{
    public class AppDbContext : DbContext
    {
        static AppDbContext()
        {

        }
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            var tKeys = new KeyValuePair<Type, string>[] {
                new KeyValuePair<Type,string>(typeof(IEntity<int>),"int"),
                new KeyValuePair<Type,string>(typeof(IEntity<long>),"bigint"),
                new KeyValuePair<Type, string>(typeof(IEntity<Guid>),"uniqueidentifier"),
                new KeyValuePair<Type, string>(typeof(IEntity<string>),"varchar")
            };

            foreach (KeyValuePair<Type, string> tKey in tKeys)
            {
                foreach (Type type in Base.Util.GetAllTypesOf(tKey.Key)/*.Where(_ => _ != typeof(Entity<Guid>))*/)
                {
                    try
                    {
                        modelBuilder.Entity(type)
                                    .ToTable(type.Name)
                                    .Property("Id").HasColumnName("Id")
                                    .HasColumnType(tKey.Value)
                                    .HasDefaultValue()
                                    ;
                    }
                    catch { }
                }
            }
        }
    }
}<commit_msg>Fix EF sql column type unit<commit_after>﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace core.Extensions.Data
{
    public class AppDbContext : DbContext
    {
        static AppDbContext()
        {

        }
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            var tKeys = new KeyValuePair<Type, int>[] {
                new KeyValuePair<Type,int>(typeof(IEntity<int>),11),
                new KeyValuePair<Type,int>(typeof(IEntity<long>),20),
                new KeyValuePair<Type, int>(typeof(IEntity<Guid>),36),
                new KeyValuePair<Type, int>(typeof(IEntity<string>),255)
            };

            foreach (KeyValuePair<Type, int> tKey in tKeys)
            {
                foreach (Type type in Base.Util.GetAllTypesOf(tKey.Key)/*.Where(_ => _ != typeof(Entity<Guid>))*/)
                {
                    try
                    {
                        modelBuilder.Entity(type)
                                    .ToTable(type.Name)
                                    .Property("Id").HasColumnName("Id")
                                    .IsUnicode(false)
                                    .HasMaxLength(tKey.Value)
                                    //.HasColumnType(tKey.Value)
                                    .HasDefaultValue()
                                    ;
                    }
                    catch { }
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09838472834067548, 'fraction_numerical': 0.0026431718061674008, 'mean_word_length': 1.4311206281227695, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7571138', 'n_tokens_mistral': 874, 'n_tokens_neox': 828, 'n_words': 139}