using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using System.ComponentModel.DataAnnotations; namespace DamageAssesment.Api.Documents.Db { public class DocumentDbContext : DbContext { private IConfiguration _Configuration { get; set; } public DocumentDbContext(DbContextOptions options, IConfiguration configuration) : base(options) { _Configuration = configuration; } public DbSet Documents { get; set; } public DbSet LinkTypes { get; set; } public DbSet DocumentsTranslations { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder options) { // connect to sql server with connection string from app settings options.UseSqlServer(_Configuration.GetConnectionString("DocumentConnection")); } 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(); } } }