Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions DataAccess/CargasHoras.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Entities;
public class CargaHoras
{
public int CargaHorasId { get; set; }

public int UsuarioId { get; set; }
public Usuario Usuario { get; set; }

public int ProyectoId { get; set; }
public Proyecto Proyecto { get; set; }

public int HorasTrabajadas { get; set; }
public string Descripcion { get; set; }
}

19 changes: 19 additions & 0 deletions DataAccess/DataAccess.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions DataAccess/Dbcontext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
using Entities;
public class ApplicationDbContext : DbContext
{
public DbSet<Proyecto> Proyectos { get; set; }
public DbSet<Usuario> Usuarios { get; set; }
public DbSet<CargaHoras> CargasHoras { get; set; }



protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Server=.;Database=RegistroDB; Trusted_Connection=True; Integrated Security=true; Encrypt=False;");
}

}
137 changes: 137 additions & 0 deletions DataAccess/Migrations/20231101124236_InitialApplicationDB.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 103 additions & 0 deletions DataAccess/Migrations/20231101124236_InitialApplicationDB.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace DataAccess.Migrations
{
/// <inheritdoc />
public partial class InitialApplicationDB : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Proyectos",
columns: table => new
{
ProyectoId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nombre = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Proyectos", x => x.ProyectoId);
});

migrationBuilder.CreateTable(
name: "Usuarios",
columns: table => new
{
UsuarioId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nombre = table.Column<string>(type: "nvarchar(max)", nullable: false),
ProyectoId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Usuarios", x => x.UsuarioId);
table.ForeignKey(
name: "FK_Usuarios_Proyectos_ProyectoId",
column: x => x.ProyectoId,
principalTable: "Proyectos",
principalColumn: "ProyectoId",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateTable(
name: "CargasHoras",
columns: table => new
{
CargaHorasId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UsuarioId = table.Column<int>(type: "int", nullable: false),
ProyectoId = table.Column<int>(type: "int", nullable: false),
HorasTrabajadas = table.Column<int>(type: "int", nullable: false),
Descripcion = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CargasHoras", x => x.CargaHorasId);
table.ForeignKey(
name: "FK_CargasHoras_Proyectos_ProyectoId",
column: x => x.ProyectoId,
principalTable: "Proyectos",
principalColumn: "ProyectoId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CargasHoras_Usuarios_UsuarioId",
column: x => x.UsuarioId,
principalTable: "Usuarios",
principalColumn: "UsuarioId",
onDelete: ReferentialAction.NoAction);
});

migrationBuilder.CreateIndex(
name: "IX_CargasHoras_ProyectoId",
table: "CargasHoras",
column: "ProyectoId");

migrationBuilder.CreateIndex(
name: "IX_CargasHoras_UsuarioId",
table: "CargasHoras",
column: "UsuarioId");

migrationBuilder.CreateIndex(
name: "IX_Usuarios_ProyectoId",
table: "Usuarios",
column: "ProyectoId");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CargasHoras");

migrationBuilder.DropTable(
name: "Usuarios");

migrationBuilder.DropTable(
name: "Proyectos");
}
}
}
Loading