123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace InvestTracker.Entities;
- public partial class InvestContext : DbContext
- {
- public InvestContext()
- {
- }
- public InvestContext(DbContextOptions<InvestContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Employee> Employees { get; set; }
- public virtual DbSet<Title> Titles { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- try {
- optionsBuilder.UseSqlServer("Data Source=srv-wsr\\is3;Initial Catalog=invest;User ID=user12;Password=user12;Encrypt=False");
- } catch {
- optionsBuilder.UseSqlServer("Data Source=vpmt.ru\\is3;Initial Catalog=invest;User ID=user12;Password=user12;Encrypt=False");
- }
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Employee>(entity =>
- {
- entity.ToTable("employee");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Birthday)
- .HasColumnType("date")
- .HasColumnName("birthday");
- entity.Property(e => e.Email)
- .HasMaxLength(64)
- .IsUnicode(false)
- .HasColumnName("email");
- entity.Property(e => e.Name)
- .HasMaxLength(50)
- .IsUnicode(false)
- .HasColumnName("name");
- entity.Property(e => e.Patronymic)
- .HasMaxLength(50)
- .IsUnicode(false)
- .HasColumnName("patronymic");
- entity.Property(e => e.Phone)
- .HasMaxLength(32)
- .IsUnicode(false)
- .HasColumnName("phone");
- entity.Property(e => e.Surname)
- .HasMaxLength(50)
- .IsUnicode(false)
- .HasColumnName("surname");
- entity.Property(e => e.TitleId).HasColumnName("title_id");
- entity.HasOne(d => d.Title).WithMany(p => p.Employees)
- .HasForeignKey(d => d.TitleId)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_employee_title");
- });
- modelBuilder.Entity<Title>(entity =>
- {
- entity.ToTable("title");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Name)
- .HasMaxLength(64)
- .IsUnicode(false)
- .HasColumnName("name");
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|