23d00eb9cd
Update DEBUG
74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
using Maat.Data.DbModels;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection.PortableExecutable;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Maat.Data
|
|
{
|
|
public partial class TaskRunContext : DbContext
|
|
{
|
|
#region Private Fields
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private string connString = "";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Public Constructors
|
|
|
|
/// <summary>
|
|
/// Init context del DB x gestione Task
|
|
/// </summary>
|
|
/// <param name="cString"></param>
|
|
public TaskRunContext(string cString)
|
|
{
|
|
connString = cString;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
public virtual DbSet<TaskListModel> DbSetTaskList { get; set; } = null!;
|
|
public virtual DbSet<TaskExecModel> DbSetTaskExe { get; set; } = null!;
|
|
public virtual DbSet<TaskResultModel> DbSetTaskResult { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
optionsBuilder.UseSqlServer(connString);
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
|
|
|
// fix x ritorno tracciato senza tabella corrispondente:
|
|
// https://stackoverflow.com/questions/50276906/dbcontext-set-cannot-create-a-dbset-for-entity-because-this-type-is-not-includ
|
|
modelBuilder.Entity<TaskResultModel>().HasNoKey();
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
}
|