private async Task InitializeDbContextAsync(string kernelName, MsSqlKernelConnector options, KernelInvocationContext context)
        {
            CSharpKernel csharpKernel = null;

            context.HandlingKernel.VisitSubkernelsAndSelf(k =>
            {
                if (k is CSharpKernel csk)
                {
                    csharpKernel = csk;
                }
            });

            if (csharpKernel is null)
            {
                return;
            }

            context.DisplayAs($"Scaffolding a `DbContext` and initializing an instance of it called `{kernelName}` in the C# kernel.", "text/markdown");

            var submission1 = @$ "  
#r " "nuget: Microsoft.EntityFrameworkCore.Design, 6.0.0" "
#r " "nuget: Microsoft.EntityFrameworkCore.SqlServer, 6.0.0" "
#r " "nuget: Humanizer.Core, 2.8.26" "
#r " "nuget: Humanizer, 2.8.26" "
#r " "nuget: Microsoft.Identity.Client, 4.35.1" "

            using System;
using System.Reflection;
using System.Linq;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Scaffolding;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddEntityFrameworkDesignTimeServices();
var providerAssembly = Assembly.Load(" "Microsoft.EntityFrameworkCore.SqlServer" ");
var providerServicesAttribute = providerAssembly.GetCustomAttribute<DesignTimeProviderServicesAttribute>();
var providerServicesType = providerAssembly.GetType(providerServicesAttribute.TypeName);
var providerServices = (IDesignTimeServices)Activator.CreateInstance(providerServicesType);
providerServices.ConfigureDesignTimeServices(services);

var serviceProvider = services.BuildServiceProvider();
var scaffolder = serviceProvider.GetService<IReverseEngineerScaffolder>();

var model = scaffolder.ScaffoldModel(
    @" "{options.ConnectionString}" ",
    new DatabaseModelFactoryOptions(),
    new ModelReverseEngineerOptions(),
    new ModelCodeGenerationOptions()
    {{
        ContextName = " "{kernelName}Context" ",
        ModelNamespace = " "{kernelName}" "
    }});
        private async Task LoadScriptExtensionFromDirectory(
            DirectoryInfo directory,
            Kernel kernel,
            KernelInvocationContext context)
        {
            var extensionFile = new FileInfo(Path.Combine(directory.FullName, ExtensionScriptName));

            if (extensionFile.Exists)
            {
                var logMessage = $"Loading extension script from `{extensionFile.FullName}`";
                using var op = new ConfirmationLogger(
                          Log.Category,
                          message: logMessage,
                          logOnStart: true,
                          args: new object[] { extensionFile });

                context.DisplayAs(logMessage, "text/markdown");

                var scriptContents = File.ReadAllText(extensionFile.FullName, Encoding.UTF8);
                await kernel.SubmitCodeAsync(scriptContents);
            }
        }
        private async Task LoadFromAssembly(
            FileInfo assemblyFile,
            Kernel kernel,
            KernelInvocationContext context)
        {
            if (assemblyFile is null)
            {
                throw new ArgumentNullException(nameof(assemblyFile));
            }

            if (kernel is null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            if (!assemblyFile.Exists)
            {
                throw new ArgumentException($"File {assemblyFile.FullName} doesn't exist", nameof(assemblyFile));
            }

            bool loadExtensions;

            lock (_lock)
            {
                loadExtensions = _loadedAssemblies.Add(AssemblyName.GetAssemblyName(assemblyFile.FullName));
            }

            if (loadExtensions)
            {
                var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyFile.FullName);

                var extensionTypes = assembly
                                     .ExportedTypes
                                     .Where(t => t.CanBeInstantiated() && typeof(IKernelExtension).IsAssignableFrom(t))
                                     .ToArray();

                if (extensionTypes.Any())
                {
                    context.DisplayAs($"Loading extensions from `{assemblyFile.Name}`", "text/markdown");
                }

                foreach (var extensionType in extensionTypes)
                {
                    var extension = (IKernelExtension)Activator.CreateInstance(extensionType);

                    try
                    {
                        await extension.OnLoadAsync(kernel);

                        context.Publish(new KernelExtensionLoaded(extension, context.Command));
                    }
                    catch (Exception e)
                    {
                        context.Publish(new ErrorProduced(
                                            $"Failed to load kernel extension \"{extensionType.Name}\" from assembly {assemblyFile.FullName}",
                                            context.Command));

                        context.Fail(context.Command, new KernelExtensionLoadException(e));
                    }
                }
            }
        }