132 lines
3.8 KiB
C#
132 lines
3.8 KiB
C#
using EgtBEAMWALL.DataLayer.DatabaseModels;
|
|
using MySql.Data.EntityFramework;
|
|
using System;
|
|
using System.Data.Entity;
|
|
using System.Data.Entity.Infrastructure;
|
|
using System.IO;
|
|
|
|
namespace EgtBEAMWALL.DataLayer
|
|
{
|
|
#if false
|
|
//[DbConfigurationType(typeof(MySqlEFConfiguration))]
|
|
public class aMySqlConfiguration : MySqlEFConfiguration
|
|
{
|
|
#region Public Constructors
|
|
|
|
public aMySqlConfiguration() : base()
|
|
{
|
|
var path = Path.GetDirectoryName(this.GetType().Assembly.Location);
|
|
SetModelStore(new DefaultDbModelStore(path));
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
}
|
|
#endif
|
|
|
|
[DbConfigurationType(typeof(MySqlEFConfiguration))]
|
|
public class DatabaseContext : DbContext
|
|
{
|
|
#region Public Constructors
|
|
|
|
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")]
|
|
public DatabaseContext() : base(DbConfig.CONNECTION_STRING)
|
|
{
|
|
}
|
|
|
|
public DatabaseContext(string connectionString) : base(connectionString)
|
|
{
|
|
Database.CreateIfNotExists();
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
|
{
|
|
#if false
|
|
// fix valori decimal
|
|
modelBuilder.Entity<MaterialModel>().Property(x => x.HMm).HasPrecision(18, 6);
|
|
modelBuilder.Entity<MaterialModel>().Property(x => x.LMm).HasPrecision(18, 6);
|
|
modelBuilder.Entity<MaterialModel>().Property(x => x.WMm).HasPrecision(18, 6);
|
|
modelBuilder.Entity<RawItemModel>().Property(x => x.HMm).HasPrecision(18, 6);
|
|
modelBuilder.Entity<RawItemModel>().Property(x => x.LMm).HasPrecision(18, 6);
|
|
modelBuilder.Entity<RawItemModel>().Property(x => x.WMm).HasPrecision(18, 6);
|
|
#endif
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// BTLParts management
|
|
/// </summary>
|
|
public DbSet<BTLPartModel> BTLPartList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Machine Log management
|
|
/// </summary>
|
|
public DbSet<LogMachineModel> LogMachineList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Support Log management
|
|
/// </summary>
|
|
public DbSet<LogSupportModel> LogSupportList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Parts management
|
|
/// </summary>
|
|
public DbSet<MachGroupModel> MachGroupList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Parts management
|
|
/// </summary>
|
|
public DbSet<PartModel> PartList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Parts management
|
|
/// </summary>
|
|
public DbSet<ProdModel> ProdList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Parts management
|
|
/// </summary>
|
|
public DbSet<ProjModel> ProjList { get; set; }
|
|
|
|
/// <summary>
|
|
/// StatusMap management
|
|
/// </summary>
|
|
public DbSet<StatusMapModel> StatusMapList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Wharehouse materials management
|
|
/// </summary>
|
|
public DbSet<MaterialModel> MaterialsList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Wharehouse items management
|
|
/// </summary>
|
|
public DbSet<RawItemModel> RawItemList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Alias management
|
|
/// </summary>
|
|
public DbSet<AliasModel> AliasList { get; set; }
|
|
|
|
/// <summary>
|
|
/// Alias management
|
|
/// </summary>
|
|
public DbSet<MagmanSyncModel> SyncList { get; set; }
|
|
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public static DatabaseContext Create()
|
|
{
|
|
return new DatabaseContext(DbConfig.CONNECTION_STRING);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |