2023-08-31 18:00:51 -05:00
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
|
namespace DamageAssesment.Api.DocuLinks.Db
|
2023-08-31 18:00:51 -05:00
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
|
public class DoculinkDbContext : DbContext
|
2023-08-31 18:00:51 -05:00
|
|
|
|
{
|
2023-09-13 12:16:42 -05:00
|
|
|
|
private IConfiguration _Configuration { get; set; }
|
2023-09-26 11:40:55 -05:00
|
|
|
|
public DoculinkDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
2023-08-31 18:00:51 -05:00
|
|
|
|
{
|
2023-09-13 12:16:42 -05:00
|
|
|
|
_Configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
|
|
|
{
|
|
|
|
|
// connect to sql server with connection string from app settings
|
2023-10-19 14:59:02 -05:00
|
|
|
|
options.UseSqlServer(_Configuration.GetConnectionString("DoculinkConnection"));
|
2023-08-31 18:00:51 -05:00
|
|
|
|
}
|
2023-09-22 10:52:17 -05:00
|
|
|
|
public DbSet<Db.Doculink> Documents { get; set; }
|
2023-08-31 18:00:51 -05:00
|
|
|
|
public DbSet<Db.LinkType> LinkTypes { get; set; }
|
2023-09-22 10:52:17 -05:00
|
|
|
|
public DbSet<Db.DoculinkTranslation> DocumentsTranslations { get; set; }
|
|
|
|
|
public DbSet<Db.LinksTranslation> LinksTranslations { get; set; }
|
|
|
|
|
public DbSet<Db.DoculinkAttachments> DoclinksAttachments { get; set; }
|
2023-08-31 18:00:51 -05:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
base.OnModelCreating(modelBuilder);
|
2023-09-22 10:52:17 -05:00
|
|
|
|
modelBuilder.Entity<Doculink>()
|
2023-08-31 18:00:51 -05:00
|
|
|
|
.Property(item => item.Id)
|
|
|
|
|
.ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<LinkType>()
|
|
|
|
|
.Property(item => item.Id)
|
|
|
|
|
.ValueGeneratedOnAdd();
|
2023-09-22 10:52:17 -05:00
|
|
|
|
modelBuilder.Entity<DoculinkTranslation>()
|
|
|
|
|
.Property(item => item.Id)
|
|
|
|
|
.ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<LinksTranslation>()
|
|
|
|
|
.Property(item => item.Id)
|
|
|
|
|
.ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<DoculinkAttachments>()
|
2023-08-31 18:00:51 -05:00
|
|
|
|
.Property(item => item.Id)
|
|
|
|
|
.ValueGeneratedOnAdd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|