TILT-AMS – about my software-part 21

One of the most related are data that fill the database for developer – and do not fill into production

AMS ( About My Software) could help . It generates an unique class that inherits

public class AboutMySoftware
{

public string Authors { get; set; }

public bool IsInCI { get; set; }

public string SourceCommit { get; set; }

public string CISourceControl { get; set; }

public string AssemblyName { get; set; }

public DateTime DateGenerated { get; set; }

public string CommitId { get; set; }

public string RepoUrl { get; set; }

}
    

The IsInCI recognizes if it is build on CI( deployed to prod lately ) or without (in the dev PC)

So I use like this

bool IsBuildFromCI = new XAboutMySoftware_78102118871091131225395110108769286().IsInCI;
if (IsBuildFromCI)
{
    hc.AddSqlServer(builder.Configuration["ConnectionStrings:DefaultConnection"],name:"database SqlServer");
}
else
{
    hc.AddSqlite(cnSqlite, name: "database Sqlite");
}

if (!IsBuildFromCI)
{
    using (var scope = app.Services.CreateScope())
    {
        if (File.Exists("Tilt.db"))
            File.Delete("Tilt.db");

        var dbcontext = scope.ServiceProvider.GetRequiredService<ApplicationDBContext>();
        dbcontext.Database.EnsureCreated();

        //seed db
        dbcontext.TILT_URL.Add(new TILT_URL()
        {
            Secret = "Andrei",
            URLPart = "TestAddWithNoData"
        });
        dbcontext.TILT_URL.Add(new TILT_URL()
        {
            Secret = "test",
            URLPart = "ClickToSeeMyTILTS"
        });
        await dbcontext.SaveChangesAsync();
}

Tools used

Visual Studio

AMS ( About My Software) – https://github.com/ignatandrei/RSCG_AMS/