Migracion hecha y bug arreglado

Habia un bug en la inyeccion de dependencias de infrastructure, se estaba intentado hacer un servicio usando interfaz + interfaz en vez de intefaz + clase...
This commit is contained in:
Alejandro Sarmiento
2024-02-18 13:35:55 +01:00
parent 026ed77c76
commit fa79ef8823
5 changed files with 323 additions and 1 deletions

View File

@@ -7,6 +7,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

View File

@@ -1,6 +1,7 @@
using CleanArchitecture.Application.Contracts.Infrastructure;
using CleanArchitecture.Application.Contracts.Persistence;
using CleanArchitecture.Application.Models;
using CleanArchitecture.Infrastructure.Email;
using CleanArchitecture.Infrastructure.Persistence;
using CleanArchitecture.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
@@ -26,7 +27,7 @@ namespace CleanArchitecture.Infrastructure
services.AddScoped<IStreamerRepository, StreamerRepository>();
services.Configure<EmailSettings>(c =>configuration.GetSection("EmailSettings"));
services.AddTransient<IEmailService, IEmailService>();
services.AddTransient<IEmailService, EmailService>();
return services;
}

View File

@@ -0,0 +1,230 @@
// <auto-generated />
using System;
using CleanArchitecture.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace CleanArchitecture.Data.Migrations
{
[DbContext(typeof(StreamerDbContext))]
[Migration("20240218123327_cleanArchitectureFromApi")]
partial class cleanArchitectureFromApi
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("CleanArchitecture.Domain.Actor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Apellido")
.HasColumnType("longtext");
b.Property<string>("CreatedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<string>("LastModifiedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("LastModifiedDate")
.HasColumnType("datetime(6)");
b.Property<string>("Nombre")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Actor");
});
modelBuilder.Entity("CleanArchitecture.Domain.Director", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Apellido")
.HasColumnType("longtext");
b.Property<string>("CreatedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<string>("LastModifiedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("LastModifiedDate")
.HasColumnType("datetime(6)");
b.Property<string>("Nombre")
.HasColumnType("longtext");
b.Property<int>("VideoId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Director");
});
modelBuilder.Entity("CleanArchitecture.Domain.Streamer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("CreatedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<string>("LastModifiedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("LastModifiedDate")
.HasColumnType("datetime(6)");
b.Property<string>("Nombre")
.HasColumnType("longtext");
b.Property<string>("Url")
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Streamers");
});
modelBuilder.Entity("CleanArchitecture.Domain.Video", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("CreatedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<int?>("DirectorId")
.HasColumnType("int");
b.Property<string>("LastModifiedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("LastModifiedDate")
.HasColumnType("datetime(6)");
b.Property<string>("Nombre")
.HasColumnType("longtext");
b.Property<int>("StreamerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DirectorId")
.IsUnique();
b.HasIndex("StreamerId");
b.ToTable("Videos");
});
modelBuilder.Entity("CleanArchitecture.Domain.VideoActor", b =>
{
b.Property<int>("VideoId")
.HasColumnType("int");
b.Property<int>("ActorId")
.HasColumnType("int");
b.Property<string>("CreatedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<int>("Id")
.HasColumnType("int");
b.Property<string>("LastModifiedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("LastModifiedDate")
.HasColumnType("datetime(6)");
b.HasKey("VideoId", "ActorId");
b.HasIndex("ActorId");
b.ToTable("VideoActor");
});
modelBuilder.Entity("CleanArchitecture.Domain.Video", b =>
{
b.HasOne("CleanArchitecture.Domain.Director", "Director")
.WithOne("Video")
.HasForeignKey("CleanArchitecture.Domain.Video", "DirectorId");
b.HasOne("CleanArchitecture.Domain.Streamer", "Streamer")
.WithMany("Videos")
.HasForeignKey("StreamerId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Director");
b.Navigation("Streamer");
});
modelBuilder.Entity("CleanArchitecture.Domain.VideoActor", b =>
{
b.HasOne("CleanArchitecture.Domain.Actor", "Actor")
.WithMany()
.HasForeignKey("ActorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CleanArchitecture.Domain.Video", "Video")
.WithMany()
.HasForeignKey("VideoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Actor");
b.Navigation("Video");
});
modelBuilder.Entity("CleanArchitecture.Domain.Director", b =>
{
b.Navigation("Video");
});
modelBuilder.Entity("CleanArchitecture.Domain.Streamer", b =>
{
b.Navigation("Videos");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,72 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CleanArchitecture.Data.Migrations
{
/// <inheritdoc />
public partial class cleanArchitectureFromApi : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
table: "VideoActor",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<DateTime>(
name: "CreatedDate",
table: "VideoActor",
type: "datetime(6)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Id",
table: "VideoActor",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "LastModifiedBy",
table: "VideoActor",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<DateTime>(
name: "LastModifiedDate",
table: "VideoActor",
type: "datetime(6)",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "VideoActor");
migrationBuilder.DropColumn(
name: "CreatedDate",
table: "VideoActor");
migrationBuilder.DropColumn(
name: "Id",
table: "VideoActor");
migrationBuilder.DropColumn(
name: "LastModifiedBy",
table: "VideoActor");
migrationBuilder.DropColumn(
name: "LastModifiedDate",
table: "VideoActor");
}
}
}

View File

@@ -154,6 +154,21 @@ namespace CleanArchitecture.Data.Migrations
b.Property<int>("ActorId")
.HasColumnType("int");
b.Property<string>("CreatedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<int>("Id")
.HasColumnType("int");
b.Property<string>("LastModifiedBy")
.HasColumnType("longtext");
b.Property<DateTime?>("LastModifiedDate")
.HasColumnType("datetime(6)");
b.HasKey("VideoId", "ActorId");
b.HasIndex("ActorId");