SharpCoreDB.CrudApp is an ASP.NET Core MVC (.NET 10) showcase for:
- Encrypted single-file storage (
.scdb, AES-256-GCM) - Lightweight auth via
SharpCoreDB.Identity - Full Product CRUD with categories
- Development-only reset workflow
- Automatic startup schema initialization
- Identity tables (
Users,Roles,UserRoles,UserClaims,UserLogins,RoleClaims) - Demo tables (
Products,Categories)
- Identity tables (
- Cookie authentication with custom account pages
- Full CRUD product management protected by authorization
- Development-only
/Admin/ResetDatabasewith destructive confirmation - Optional admin seed account after reset:
admin / Admin123!
Settings are in appsettings.json under SharpCoreDb and SharpCoreIdentity.
Warning: never keep production secrets in
appsettings.json.
Use development user-secrets:
dotnet user-secrets set "SharpCoreDb:EncryptionPassword" "your-strong-password"
dotnet user-secrets set "SharpCoreDb:MasterPassword" "your-master-password"dotnet restore
cd Examples/Web/SharpCoreDB.CrudApp
dotnet runBrowse to https://localhost:7101.
Program.cs performs:
- DI registration for SharpCoreDB core + Identity
- Encrypted database factory setup
- Startup
EnsureInitializedAsync(...) - EF provider
EnsureCreatedAsync()for model mapping compatibility
- Login as
admin - Open
/Admin/ResetDatabase - Confirm reset prompt
The app deletes the existing .scdb file, recreates schema, and reseeds the admin user.
Services/SharpCoreCrudDatabaseService.cs- encrypted database construction
- schema initialization
- reset + seed logic
Services/ProductCrudService.cs- async CRUD abstraction over SharpCoreDB SQL
Controllers/ProductsController.cs- authorized MVC CRUD endpoints
Controllers/AccountController.cs- register/login/logout
- This sample is optimized for local demo and developer onboarding.
- For production, harden secret handling, add CSRF/security auditing policies, and implement richer authorization policies/roles.