Tienda Mi Cholo uses a SQL Server database namedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/interezante456-pixel/nuevo-proyecto-viernes/llms.txt
Use this file to discover all available pages before exploring further.
TIENDA_MICHOLO, managed entirely by Entity Framework Core 10 (package version 10.0.9). The schema is declared through AppDbContext in Final_proyecto.Data and versioned through three EF Core migrations. Seven entity tables cover system users, access roles, product categories, the product catalog, customer records, sale headers, and sale line items. Seed data baked into the initial migration ensures the application starts with the three standard roles, a default admin account, a public-general client placeholder, and six product categories.
Tables
| Table | DbSet | Primary Key | Description |
|---|---|---|---|
Usuarios | AppDbContext.Usuarios | ID_Usuario | System user accounts with login credentials and role assignment |
Roles | AppDbContext.Roles | ID_Rol | Access roles used for authorization (Administrador, Gerente, Cajero) |
Categorias | AppDbContext.Categorias | ID_Categoria | Product category definitions used to organise the catalog |
Productos | AppDbContext.Productos | ID_Producto | Product catalog including pricing, stock, and active/inactive status |
Clientes | AppDbContext.Clientes | ID_Cliente | Customer records; ID 1 is the reserved Público General placeholder |
Ventas | AppDbContext.Ventas | ID_Venta | Sale headers: voucher type, number, date, total, and foreign keys to client and user |
DetalleVentas | AppDbContext.DetalleVentas | ID_DetalleVenta | Sale line items: quantity, unit price, subtotal, and foreign keys to sale and product |
Foreign Key Relationships
The following relationships are configured inAppDbContext.OnModelCreating using EF Core’s fluent API:
| Dependent | Foreign Key | Principal | Cardinality |
|---|---|---|---|
Usuario | Rol_ID | Roles.ID_Rol | Many-to-one |
Producto | Categoria_ID | Categorias.ID_Categoria | Many-to-one |
Venta | Cliente_ID | Clientes.ID_Cliente | Many-to-one |
DetalleVenta | Venta_ID | Ventas.ID_Venta | Many-to-one |
DetalleVenta | Producto_ID | Productos.ID_Producto | Many-to-one |
CASCADE delete in the initial migration, meaning deleting a parent record will also delete its dependents (e.g., deleting a Venta cascades to its DetalleVentas).
AppDbContext Configuration
TheOnModelCreating method configures every relationship with explicit HasOne / WithMany / HasForeignKey chains and then seeds the reference data:
DbSet declarations in AppDbContext:
Connecting to the Database
The connection string is stored inappsettings.json under the key CadenaSQL:
Program.cs reads this key and registers AppDbContext with the DI container:
The default configuration targets
(localdb)\MSSQLLocalDB, which ships with Visual Studio. To deploy to a named SQL Server instance, update the Data Source and replace Trusted_Connection=True with User Id / Password credentials, or switch to a managed-identity connection string.Managing the Database
Use the EF Core CLI tools to manage schema changes. All commands should be run from the project directory (where the.csproj file lives).
Apply all pending migrations to create or update the database:
AppDbContext:
AddEstadoToProducto migration was applied: