using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore; namespace API.BaseModel; public partial class AstashinApiContext : DbContext { public AstashinApiContext() { } public AstashinApiContext(DbContextOptions options) : base(options) { } public virtual DbSet Autos { get; set; } public virtual DbSet CarBodies { get; set; } public virtual DbSet Prices { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. => optionsBuilder.UseSqlServer("Server=sql;Database=AstashinApi;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.IdAuto); entity.ToTable("Auto"); entity.Property(e => e.IdAuto).HasColumnName("id_auto"); entity.Property(e => e.Brand) .HasMaxLength(50) .IsUnicode(false); entity.Property(e => e.Color) .HasMaxLength(50) .IsUnicode(false); entity.Property(e => e.IdCarBody).HasColumnName("id_car_body"); entity.Property(e => e.IdPrice).HasColumnName("id_price"); entity.Property(e => e.Model) .HasMaxLength(50) .IsUnicode(false); entity.HasOne(d => d.IdCarBodyNavigation).WithMany(p => p.Autos) .HasForeignKey(d => d.IdCarBody) .HasConstraintName("FK_Auto_Car_body"); entity.HasOne(d => d.IdPriceNavigation).WithMany(p => p.Autos) .HasForeignKey(d => d.IdPrice) .HasConstraintName("FK_Auto_Price"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.IdCarBody); entity.ToTable("Car_body"); entity.Property(e => e.IdCarBody).HasColumnName("id_car_body"); entity.Property(e => e.CarBody1) .HasMaxLength(50) .IsUnicode(false) .HasColumnName("Car_body"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.IdPrice).HasName("PK_Table_1"); entity.ToTable("Price"); entity.Property(e => e.IdPrice).HasColumnName("id_price"); entity.Property(e => e.Price1).HasColumnName("Price"); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); }