using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; namespace MusicAPI.BaseModel { public partial class SongListContext : DbContext { public SongListContext() { } public SongListContext(DbContextOptions options) : base(options) { } public virtual DbSet Artists { get; set; } = null!; public virtual DbSet Genres { get; set; } = null!; public virtual DbSet Songs { get; set; } = null!; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { optionsBuilder.UseSqlServer("Server=sql;Database=SongList;User ID=23П;Password=12357;Trusted_Connection=True;Integrated Security=False;Encrypt=False"); } } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasKey(e => e.IdArtist) .HasName("PK__Artists__3B155B87C5FDA726"); entity.Property(e => e.IdArtist).HasColumnName("ID_Artist"); entity.Property(e => e.NameArtist) .IsUnicode(false) .HasColumnName("Name_Artist"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.IdGenre) .HasName("PK__Genres__7B31A83B1CB13B02"); entity.Property(e => e.IdGenre).HasColumnName("ID_Genre"); entity.Property(e => e.NameGenre) .IsUnicode(false) .HasColumnName("Name_Genre"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.IdSong) .HasName("PK__Songs__EDE8C2894FE8E7DE"); entity.Property(e => e.IdSong).HasColumnName("ID_Song"); entity.Property(e => e.IdArtist).HasColumnName("ID_Artist"); entity.Property(e => e.IdGenre).HasColumnName("ID_Genre"); entity.Property(e => e.NameSong) .IsUnicode(false) .HasColumnName("Name_Song"); entity.HasOne(d => d.IdArtistNavigation) .WithMany(p => p.Songs) .HasForeignKey(d => d.IdArtist) .HasConstraintName("FK__Songs__ID_Artist__3C69FB99"); entity.HasOne(d => d.IdGenreNavigation) .WithMany(p => p.Songs) .HasForeignKey(d => d.IdGenre) .HasConstraintName("FK__Songs__ID_Genre__3D5E1FD2"); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); } }