using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using System.ComponentModel.DataAnnotations; namespace DamageAssesment.Api.DocuLinks.Db { public class DoculinkDbContext : DbContext { private IConfiguration _Configuration { get; set; } public DoculinkDbContext(DbContextOptions options, IConfiguration configuration) : base(options) { _Configuration = configuration; } protected override void OnConfiguring(DbContextOptionsBuilder options) { // connect to sql server with connection string from app settings options.UseSqlServer(_Configuration.GetConnectionString("DoculinConnection")); } public DbSet Documents { get; set; } public DbSet LinkTypes { get; set; } public DbSet DocumentsTranslations { get; set; } public DbSet LinksTranslations { get; set; } public DbSet DoclinksAttachments { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); } } }