añade inicio del back

This commit is contained in:
2025-08-07 13:36:31 +02:00
parent dc68641cfe
commit 9b373d1929
83 changed files with 63060 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
using back.ApiService.models;
using Microsoft.EntityFrameworkCore;
namespace back.ApiService.context;
public class PhotoContext : DbContext
{
public DbSet<Photo> Photos { get; set; }
public PhotoContext(DbContextOptions<PhotoContext> options) : base(options)
{
// Ensure database is created
Database.EnsureCreated();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Photo>()
.Property(p => p.Tags)
.HasConversion(
v => string.Join(',', v),
v => v.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList());
modelBuilder.Entity<Photo>()
.Property(p => p.PersonsIn)
.HasConversion(
v => string.Join(',', v),
v => v.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList());
}
}