Skip to main content

Documentation 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 Mi Cholo uses EF Core’s code-first migration system to version-control every schema change. Each migration is a timestamped C# class in the Final_proyecto.Migrations namespace that contains Up() (apply) and Down() (rollback) methods generated by the EF Core tooling. Three migrations bring the database from nothing to the current production schema. The migration history is stored in the __EFMigrationsHistory table that EF Core maintains automatically in TIENDA_MICHOLO.
Always commit migration files to source control alongside the model changes that produced them. Migrations are the authoritative record of how the schema evolved and are required to reproduce the database on any new environment.

Running Migrations

To apply all pending migrations and bring the database up to date:
dotnet ef database update
Run this command from the project directory (where Final proyecto.csproj is located) after cloning the repository or pulling new migration files.

Migration History

Migration 1 — Inicial

Timestamp: 20260706200951
Class: Inicial
This is the foundational migration. It creates all seven application tables from scratch, establishes every foreign key constraint and index, and seeds the reference data the application requires before first use.

Migration 2 — AddEstadoToProducto

Timestamp: 20260707002811
Class: AddEstadoToProducto
Adds the Estado column to the Productos table so individual products can be marked active or inactive without being deleted. Change applied:
migrationBuilder.AddColumn<bool>(
    name: "Estado",
    table: "Productos",
    type: "bit",
    nullable: false,
    defaultValue: false);
ColumnTypeNullableDefault
EstadobitNOT NULLfalse (0)
The column is added with a default of false. After applying this migration you should update any existing products to Estado = true if they are intended to be available for sale. The POST /Producto/Nuevo action always sets Estado = true for new products created through the UI.
Rollback (Down): Drops the Estado column from Productos.

Migration 3 — MakeClienteFieldsNullable

Timestamp: 20260707011120
Class: MakeClienteFieldsNullable
Makes Correo and Direccion nullable on Clientes, and also makes Descripcion nullable on Productos. This allows client records to be created without an email address or physical address — important for the boleta flow where the sale controller creates client records on the fly with minimal information. Changes applied:
TableColumnOld TypeNew Type
ClientesCorreonvarchar(100) NOT NULLnvarchar(100) NULL
ClientesDireccionnvarchar(200) NOT NULLnvarchar(200) NULL
ProductosDescripcionnvarchar(200) NOT NULLnvarchar(200) NULL
migrationBuilder.AlterColumn<string>(
    name: "Correo",
    table: "Clientes",
    type: "nvarchar(100)",
    maxLength: 100,
    nullable: true, ...);

migrationBuilder.AlterColumn<string>(
    name: "Direccion",
    table: "Clientes",
    type: "nvarchar(200)",
    maxLength: 200,
    nullable: true, ...);

migrationBuilder.AlterColumn<string>(
    name: "Descripcion",
    table: "Productos",
    type: "nvarchar(200)",
    maxLength: 200,
    nullable: true, ...);
Rollback (Down): Reverts all three columns to NOT NULL with an empty-string default ("").

Creating New Migrations

After modifying a model class or the AppDbContext, generate a new migration and apply it:
dotnet ef migrations add <MigrationName>
dotnet ef database update
Follow the existing naming convention: use descriptive PascalCase names that describe the schema change (e.g., AddTelefonoToUsuario, RenameProductoColumns).
Rolling back the Inicial migration (running dotnet ef database update 0) drops all seven tables and all data, including the seed roles, admin user, default client, and categories. The tables and seed data are recreated the next time dotnet ef database update is run, but any transactional records (sales, custom products, additional users) will be permanently lost.

Build docs developers (and LLMs) love