12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 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<SongListContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Artist> Artists { get; set; } = null!;
- public virtual DbSet<Genre> Genres { get; set; } = null!;
- public virtual DbSet<Song> 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<Artist>(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<Genre>(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<Song>(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);
- }
- }
|