Legosols.LG
1.5.25
dotnet add package Legosols.LG --version 1.5.25
NuGet\Install-Package Legosols.LG -Version 1.5.25
<PackageReference Include="Legosols.LG" Version="1.5.25" />
<PackageVersion Include="Legosols.LG" Version="1.5.25" />
<PackageReference Include="Legosols.LG" />
paket add Legosols.LG --version 1.5.25
#r "nuget: Legosols.LG, 1.5.25"
#:package Legosols.LG@1.5.25
#addin nuget:?package=Legosols.LG&version=1.5.25
#tool nuget:?package=Legosols.LG&version=1.5.25
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
- Register Company Page (
- ✅ Data Isolation (Multi-tenancy) (v1.3.1)
- Services, Leads, and Sources are now filtered by Portal.
- ⚠️ IMPORTANT: Run
Add-Migrationafter updating to v1.3.1 to addPortalIdcolumns.
- ✅ 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)AspNetRolesAspNetUserRolesAspNetUserClaimsAspNetUserLoginsAspNetUserTokensAspNetRoleClaimsServices(with 7 seed records)PortalsPortalEmployees
🎨 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
AdditionalAssembliesto Router (see Step 4)
Login not working
- Ensure
UseAuthentication()andUseAuthorization()are inProgram.cs - Add
CascadingAuthenticationStateto Routes
📞 Contact & Support
For complete source code, custom application development, or support, please visit our website:
Get in touch for enterprise solutions and dedicated support.
| Product | Versions 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. |
-
net10.0
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 10.0.1)
- Microsoft.AspNetCore.Identity.UI (>= 10.0.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 10.0.1)
- Microsoft.EntityFrameworkCore.SqlServer (>= 10.0.1)
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 |