Legosols.LG 1.5.25

dotnet add package Legosols.LG --version 1.5.25
                    
NuGet\Install-Package Legosols.LG -Version 1.5.25
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Legosols.LG" Version="1.5.25" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Legosols.LG" Version="1.5.25" />
                    
Directory.Packages.props
<PackageReference Include="Legosols.LG" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Legosols.LG --version 1.5.25
                    
#r "nuget: Legosols.LG, 1.5.25"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Legosols.LG@1.5.25
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Legosols.LG&version=1.5.25
                    
Install as a Cake Addin
#tool nuget:?package=Legosols.LG&version=1.5.25
                    
Install as a Cake Tool

LG Module - Complete Setup Guide

📦 Installation

dotnet add package LG

License Key Required: You must provide a valid Legosols License Key to use this library. Contact Legosols to obtain one.

🚀 Quick Start (3 Steps)

Step 1: Create Your DbContext

Create a new file Data/ApplicationDbContext.cs:

using LG.Data;
using Microsoft.EntityFrameworkCore;

namespace YourProject.Data;

public class ApplicationDbContext : LgDbContext
{
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) 
        : base(options)
    {
    }

    // Add your custom entities here
    // public DbSet<Customer> Customers { get; set; }
    // public DbSet<Order> Orders { get; set; }
}

Step 2: Configure Connection String

In appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=YourDb;User Id=sa;Password=YourPassword;TrustServerCertificate=true;"
  }
}

Step 3: Register Services in Program.cs

using YourProject.Data;
using LG.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add Blazor services
builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

builder.Services.AddControllers();
builder.Services.AddCascadingAuthenticationState();

// ✅ ONE LINE - Registers everything! requires LEGSOLS License Key
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddLgServices<ApplicationDbContext>(
    options => options.UseSqlServer(connectionString),
    lgOptions => lgOptions.LicenseKey = "YOUR_LICENSE_KEY_HERE");

var app = builder.Build();

// Auto-migrate database
using (var scope = app.Services.CreateScope())
{
    var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
    db.Database.Migrate();
}

// Configure middleware
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();

app.MapStaticAssets();
app.MapControllers();
app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode();

app.Run();

Step 4: Update Routes.razor

@using Microsoft.AspNetCore.Components.Authorization

<CascadingAuthenticationState>
    <Router AppAssembly="typeof(Program).Assembly" 
            AdditionalAssemblies="@(new[] { typeof(LG.Extensions.LgServiceCollectionExtensions).Assembly })">
        <Found Context="routeData">
            <AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
                <NotAuthorized>
                    @{
                        NavigationManager.NavigateTo("/admin/login", true);
                    }
                </NotAuthorized>
            </AuthorizeRouteView>
        </Found>
    </Router>
</CascadingAuthenticationState>

@inject NavigationManager NavigationManager

Step 5: Create Migration

dotnet ef migrations add InitialCreate --context ApplicationDbContext

Step 6: Run!

dotnet run

Navigate to /admin/register to create your first user!


🎁 What You Get Automatically

  • ✅ Identity System with custom columns (UserTypeId, PortalId, EnterpriseId, UserCustomId)
  • ✅ Login/Register Pages (/admin/login, /admin/register)
  • ✅ Services CRUD (/admin/services - List, Add, Edit, Delete)
  • ✅ Tenant Registration (New in v1.2.0)
    • Register Company Page (/admin/register-company)
    • Auto-creates Portal + Admin User + PortalEmployee
  • ✅ Data Isolation (Multi-tenancy) (v1.3.1)
    • Services, Leads, and Sources are now filtered by Portal.
    • ⚠️ IMPORTANT: Run Add-Migration after updating to v1.3.1 to add PortalId columns.
  • ✅ Portals & PortalEmployees tables
  • ✅ Toast Notifications (IToastService)
  • ✅ Global Loader (ILoaderService)
  • ✅ Theme Personalization (IUserThemeService)
    • Auto-creates and saves user preferences per user.
  • ✅ Admin Layout with sidebar

🔧 Extending LG Tables

You can add columns to LG tables using partial classes:

Create Entities/EntityExtensions.cs:

using System.ComponentModel.DataAnnotations;

namespace LG.Entities;  // ⚠️ Must use same namespace!

public partial class Portal
{
    [MaxLength(200)]
    public string? Address { get; set; }
    
    [MaxLength(20)]
    public string? PhoneNumber { get; set; }
    
    public DateTime? EstablishedDate { get; set; }
}

public partial class PortalEmployee
{
    [MaxLength(100)]
    public string? Email { get; set; }
    
    public DateTime? JoinDate { get; set; }
}

public partial class ServiceItem
{
    [MaxLength(500)]
    public string? Description { get; set; }
    
    public bool IsFeatured { get; set; }
}

Then create migration:

dotnet ef migrations add AddExtendedColumns --context ApplicationDbContext

Columns will be added to the same tables!


📝 Using LG Services

Toast Notifications

@inject IToastService ToastService

// In your code
ToastService.ShowSuccess("Saved successfully!");
ToastService.ShowError("Something went wrong!");
ToastService.ShowWarning("Please check your input");
ToastService.ShowInfo("FYI: New update available");

Global Loader

@inject ILoaderService LoaderService

private async Task SaveData()
{
    LoaderService.Show();
    try
    {
        await _repository.SaveAsync();
        ToastService.ShowSuccess("Saved!");
    }
    finally
    {
        LoaderService.Hide();
    }
}

Theme Service

@inject IUserThemeService ThemeService

// Get current user's theme
var theme = await ThemeService.GetThemeAsync(userId);
theme.PrimaryColor = "#ff0000";
await ThemeService.SaveThemeAsync(theme);

Service Repository

@inject IServiceRepository ServiceRepo

var services = await ServiceRepo.GetAllAsync();
var service = await ServiceRepo.GetByIdAsync(1);
await ServiceRepo.AddAsync(newService);
await ServiceRepo.UpdateAsync(service);
await ServiceRepo.DeleteAsync(1);

🗄️ Database Tables Created

  • AspNetUsers (with custom columns)
  • AspNetRoles
  • AspNetUserRoles
  • AspNetUserClaims
  • AspNetUserLogins
  • AspNetUserTokens
  • AspNetRoleClaims
  • Services (with 7 seed records)
  • Portals
  • PortalEmployees

🎨 Customizing Layout

Override MainLayout.razor:

@inherits LayoutComponentBase
@using LG.Components.Layout

<LgLayout SidebarContent="@SidebarContent" ChildContent="@Body">
</LgLayout>

@code {
    RenderFragment SidebarContent => @<text>
        
        <a href="/" class="nav-item">Dashboard</a>
        <a href="/admin/services" class="nav-item">Services</a>
    </text>;
}

📚 Available Routes

  • / - Dashboard (requires auth)
  • /admin/login - Login page
  • /admin/register - Register page
  • /admin/logout - Logout
  • /admin/services - Services list
  • /admin/services/add - Add service
  • /admin/services/edit/{id} - Edit service

⚙️ Configuration Options

All configuration is automatic! Just inherit LgDbContext and call AddLgServices<YourContext>().


🆘 Troubleshooting

Build Error: "Cannot convert DbContextOptions"

  • Make sure your context inherits LgDbContext
  • Use DbContextOptions<YourContext> in constructor

Routes not found

  • Add AdditionalAssemblies to Router (see Step 4)

Login not working

  • Ensure UseAuthentication() and UseAuthorization() are in Program.cs
  • Add CascadingAuthenticationState to Routes

📞 Contact & Support

For complete source code, custom application development, or support, please visit our website:

👉 www.legosols.com

Get in touch for enterprise solutions and dedicated support.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.25 154 3/17/2026
1.5.24 142 2/5/2026
1.5.23 136 2/5/2026
1.5.22 129 2/5/2026
1.5.21 142 1/30/2026
1.5.20 156 1/29/2026
1.5.19 135 1/29/2026
1.5.18 125 1/29/2026
1.5.17 133 1/29/2026
1.5.16 134 1/29/2026
1.5.15 134 1/29/2026
1.5.14 143 1/28/2026
1.5.7 132 1/28/2026
1.5.6 136 1/28/2026
1.5.5 132 1/28/2026
1.5.1 133 1/28/2026
1.5.0 146 1/26/2026
1.4.7 145 1/24/2026
Loading failed