DamageAssessment_Backend/DamageAssesmentApi/DamageAssesment.Api.Attachments/Db/AttachmentsDbContext.cs
2023-09-13 13:16:42 -04:00

28 lines
1.0 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace DamageAssesment.Api.Attachments.Db
{
public class AttachmentsDbContext:DbContext
{
private IConfiguration _Configuration { get; set; }
public AttachmentsDbContext(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("AttachmentConnection"));
}
public DbSet<Db.Attachment> Attachments { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Attachment>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
}
}
}