- Server:
NB0316\SQLEXPRESS(default from connection string) - Database:
booksDb - Local connection string uses Windows auth (
Trusted_Connection=True); production/IIS uses SQL loginmvc_web(see deployment docs). - The SQL Server is SQL Server 2008 R2 compatibility level 100 — this drove two
decisions:
AuditLogControllerpages in memory (noOFFSET/FETCH).- Stored procedures use classic
CREATE PROCEDURE/ALTER PROCEDURE, neverCREATE OR ALTER.
| Table | Purpose | Managed by |
|---|---|---|
books |
Book catalog (Id, Title, Author, Price) | stored procedures (no EF writes) |
AspNetUsers, AspNetRoles, AspNetUserRoles, AspNetUserClaims, AspNetRoleClaims, AspNetUserLogins, AspNetUserTokens |
ASP.NET Identity tables | EF Core migrations |
AuditLogs |
Audit trail rows (see Models/AuditLog) |
AuditActionFilter + AuditRetentionService |
PageViews |
Page view hits (see Models/PageView) |
PageViewFilter |
| Migration | Created | Adds |
|---|---|---|
20260706023505_AddIdentityTables |
2026-07-06 | Identity tables + __EFMigrationsHistory |
20260808012119_AddAuditLogs |
2026-08-08 | AuditLogs table |
20260808024835_AddPageViews |
2026-08-08 | PageViews table |
Current model is captured in mvcContextModelSnapshot.cs.
All operate on books. Expected column shape returned by read procs:
(Id, Title, Author, Price).
| Proc | File | Purpose |
|---|---|---|
BookViewAll |
SQL/BookViewAll.sql |
SELECT * FROM books |
BookViewById @Id |
SQL/BookViewById.sql |
One row by id |
BookAdd @Id,@Title,@Author,@Price |
SQL/BookAdd.sql |
INSERT |
BookEdit @Id,@Title,@Author,@Price |
SQL/BookEdit.sql |
UPDATE |
BookAddOrEdit @Id,… |
SQL/BookAddOrEdit.sql |
INSERT if @Id=0 else UPDATE |
BookDeleteById @Id |
SQL/BookDeleteById.sql |
DELETE |
BookSearchByTitle @SearchString |
Scripts/BookSearchByTitle.sql |
LIKE search on title/author |
Notes:
BookSearchByTitleexists in theScripts/folder (created during this session) and must reproduce the same(Id, Title, Author, Price)column order becauseBookRepository.Mapreads theIdcolumn by position/name.- Parameter style:
commandType: CommandType.StoredProcedure; the exact binding lives inBookRepository.
SQL/books.sql— schema + seed (demo books) used when creatingbooksDb.SQL/booksDb.bak— SQL Server backup of the currentbooksDb.SQL/GRANT.sql— grantsEXECUTEon the book procs (addsdc_book_proc_user/web/mvc_webetc. users as appropriate).
Runs every startup inside Program.cs:
- Creates roles if missing: Admin, Member (
SeedData.AdminRole,SeedData.MemberRole). - If
Admin:Email+Admin:Passwordare configured (seeappsettings.json/ IIS env vars), creates that user, setsEmailConfirmed = true, assignsAdmin. - Failure paths are logged and non-fatal: if the DB is down or credentials missing the site still starts.
- Existing users are never re-created; upgrades to role assignment are skipped if the user already exists.