diff --git a/MP.Data/Migrations/20221111155708_InitialCreate.Designer.cs b/MP.Data/Migrations/20221111155708_InitialCreate.Designer.cs new file mode 100644 index 00000000..4db0284c --- /dev/null +++ b/MP.Data/Migrations/20221111155708_InitialCreate.Designer.cs @@ -0,0 +1,120 @@ +// +using System; +using MP.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MP.Data.Migrations +{ + [DbContext(typeof(MoonPro_InveContext))] + [Migration("20221111155708_InitialCreate")] + partial class InitialCreate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b => + { + b.Property("InveSessID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InveSessID"), 1L, 1); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DtEnd") + .HasColumnType("datetime2"); + + b.Property("DtStart") + .HasColumnType("datetime2"); + + b.Property("Transferred") + .HasColumnType("bit"); + + b.Property("UserCrea") + .HasColumnType("nvarchar(max)"); + + b.HasKey("InveSessID"); + + b.ToTable("InveSess"); + }); + + modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b => + { + b.Property("ScanID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ScanID"), 1L, 1); + + b.Property("CodArticolo") + .HasColumnType("nvarchar(max)"); + + b.Property("DtScan") + .HasColumnType("datetime2"); + + b.Property("InveSessID") + .HasColumnType("int"); + + b.Property("IsForced") + .HasColumnType("bit"); + + b.Property("IsKnown") + .HasColumnType("bit"); + + b.Property("IsUnique") + .HasColumnType("bit"); + + b.Property("Lotto") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasColumnType("nvarchar(max)"); + + b.Property("Qty") + .HasColumnType("decimal(18,2)"); + + b.Property("RifExt") + .HasColumnType("nvarchar(max)"); + + b.Property("ScanValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserScan") + .HasColumnType("nvarchar(max)"); + + b.HasKey("ScanID"); + + b.HasIndex("InveSessID"); + + b.ToTable("InveScanData"); + }); + + modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b => + { + b.HasOne("MP.Data.DatabaseModels.InventorySessionModel", "InveSessNav") + .WithMany() + .HasForeignKey("InveSessID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InveSessNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MP.Data/Migrations/20221111155708_InitialCreate.cs b/MP.Data/Migrations/20221111155708_InitialCreate.cs new file mode 100644 index 00000000..32383635 --- /dev/null +++ b/MP.Data/Migrations/20221111155708_InitialCreate.cs @@ -0,0 +1,74 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MP.Data.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "InveSess", + columns: table => new + { + InveSessID = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Description = table.Column(type: "nvarchar(max)", nullable: true), + UserCrea = table.Column(type: "nvarchar(max)", nullable: true), + DtStart = table.Column(type: "datetime2", nullable: false), + DtEnd = table.Column(type: "datetime2", nullable: true), + Transferred = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InveSess", x => x.InveSessID); + }); + + migrationBuilder.CreateTable( + name: "InveScanData", + columns: table => new + { + ScanID = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DtScan = table.Column(type: "datetime2", nullable: false), + UserScan = table.Column(type: "nvarchar(max)", nullable: true), + ScanValue = table.Column(type: "nvarchar(max)", nullable: true), + IsForced = table.Column(type: "bit", nullable: false), + CodArticolo = table.Column(type: "nvarchar(max)", nullable: true), + Lotto = table.Column(type: "nvarchar(max)", nullable: true), + RifExt = table.Column(type: "nvarchar(max)", nullable: true), + Qty = table.Column(type: "decimal(18,6)", nullable: false), + Note = table.Column(type: "nvarchar(max)", nullable: true), + IsKnown = table.Column(type: "bit", nullable: false), + IsUnique = table.Column(type: "bit", nullable: false), + InveSessID = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InveScanData", x => x.ScanID); + table.ForeignKey( + name: "FK_InveScanData_InveSess_InveSessID", + column: x => x.InveSessID, + principalTable: "InveSess", + principalColumn: "InveSessID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_InveScanData_InveSessID", + table: "InveScanData", + column: "InveSessID"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "InveScanData"); + + migrationBuilder.DropTable( + name: "InveSess"); + } + } +} diff --git a/MP.Data/Migrations/MoonPro_InveContextModelSnapshot.cs b/MP.Data/Migrations/MoonPro_InveContextModelSnapshot.cs new file mode 100644 index 00000000..d28feafa --- /dev/null +++ b/MP.Data/Migrations/MoonPro_InveContextModelSnapshot.cs @@ -0,0 +1,118 @@ +// +using System; +using MP.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MP.Data.Migrations +{ + [DbContext(typeof(MoonPro_InveContext))] + partial class MoonPro_InveContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b => + { + b.Property("InveSessID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InveSessID"), 1L, 1); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DtEnd") + .HasColumnType("datetime2"); + + b.Property("DtStart") + .HasColumnType("datetime2"); + + b.Property("Transferred") + .HasColumnType("bit"); + + b.Property("UserCrea") + .HasColumnType("nvarchar(max)"); + + b.HasKey("InveSessID"); + + b.ToTable("InveSess"); + }); + + modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b => + { + b.Property("ScanID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ScanID"), 1L, 1); + + b.Property("CodArticolo") + .HasColumnType("nvarchar(max)"); + + b.Property("DtScan") + .HasColumnType("datetime2"); + + b.Property("InveSessID") + .HasColumnType("int"); + + b.Property("IsForced") + .HasColumnType("bit"); + + b.Property("IsKnown") + .HasColumnType("bit"); + + b.Property("IsUnique") + .HasColumnType("bit"); + + b.Property("Lotto") + .HasColumnType("nvarchar(max)"); + + b.Property("Note") + .HasColumnType("nvarchar(max)"); + + b.Property("Qty") + .HasColumnType("decimal(18,2)"); + + b.Property("RifExt") + .HasColumnType("nvarchar(max)"); + + b.Property("ScanValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserScan") + .HasColumnType("nvarchar(max)"); + + b.HasKey("ScanID"); + + b.HasIndex("InveSessID"); + + b.ToTable("InveScanData"); + }); + + modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b => + { + b.HasOne("MP.Data.DatabaseModels.InventorySessionModel", "InveSessNav") + .WithMany() + .HasForeignKey("InveSessID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InveSessNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MP.Data/MoonPro_InveContext.cs b/MP.Data/MoonPro_InveContext.cs new file mode 100644 index 00000000..c8844cb6 --- /dev/null +++ b/MP.Data/MoonPro_InveContext.cs @@ -0,0 +1,86 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Configuration; +using MP.Data.DatabaseModels; +using NLog; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data +{ + public partial class MoonPro_InveContext : DbContext + { + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private IConfiguration _configuration; + + #endregion Private Fields + + #region Public Constructors + + /// + /// Indispensabile x prima generazione migrations EFCore + /// + + [Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")] + public MoonPro_InveContext() + { + } + + public MoonPro_InveContext(IConfiguration configuration) + { + _configuration = configuration; + } + + public MoonPro_InveContext(DbContextOptions options) : base(options) + { + } + + #endregion Public Constructors + + #region Public Properties + + public virtual DbSet DbInveSess { get; set; } + public virtual DbSet DbScanData { get; set; } + + #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) + { + string connString = _configuration.GetConnectionString("Mp.Inve"); + if (!string.IsNullOrEmpty(connString)) + { + optionsBuilder.UseSqlServer(connString); + } + else + { + optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_MAG;Trusted_Connection=True;"); + } + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + + OnModelCreatingPartial(modelBuilder); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP.INVE/appsettings.json b/MP.INVE/appsettings.json index d2303205..bf26110e 100644 --- a/MP.INVE/appsettings.json +++ b/MP.INVE/appsettings.json @@ -8,7 +8,7 @@ "AllowedHosts": "*", "CodApp": "MP.INVE", "ConnectionStrings": { - "Mp.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", + "Mp.Inve": "Server=SQL2016DEV;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", "Redis": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", "RedisAdmin": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true" },