Aggiunta migrazione iniziale

This commit is contained in:
Samuele Locatelli
2022-11-11 17:00:23 +01:00
parent ba207bf1ae
commit ef5eda696a
5 changed files with 399 additions and 1 deletions
@@ -0,0 +1,120 @@
// <auto-generated />
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<int>("InveSessID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("InveSessID"), 1L, 1);
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DtEnd")
.HasColumnType("datetime2");
b.Property<DateTime>("DtStart")
.HasColumnType("datetime2");
b.Property<bool>("Transferred")
.HasColumnType("bit");
b.Property<string>("UserCrea")
.HasColumnType("nvarchar(max)");
b.HasKey("InveSessID");
b.ToTable("InveSess");
});
modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b =>
{
b.Property<int>("ScanID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ScanID"), 1L, 1);
b.Property<string>("CodArticolo")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DtScan")
.HasColumnType("datetime2");
b.Property<int>("InveSessID")
.HasColumnType("int");
b.Property<bool>("IsForced")
.HasColumnType("bit");
b.Property<bool>("IsKnown")
.HasColumnType("bit");
b.Property<bool>("IsUnique")
.HasColumnType("bit");
b.Property<string>("Lotto")
.HasColumnType("nvarchar(max)");
b.Property<string>("Note")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Qty")
.HasColumnType("decimal(18,2)");
b.Property<string>("RifExt")
.HasColumnType("nvarchar(max)");
b.Property<string>("ScanValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("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
}
}
}
@@ -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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserCrea = table.Column<string>(type: "nvarchar(max)", nullable: true),
DtStart = table.Column<DateTime>(type: "datetime2", nullable: false),
DtEnd = table.Column<DateTime>(type: "datetime2", nullable: true),
Transferred = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InveSess", x => x.InveSessID);
});
migrationBuilder.CreateTable(
name: "InveScanData",
columns: table => new
{
ScanID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DtScan = table.Column<DateTime>(type: "datetime2", nullable: false),
UserScan = table.Column<string>(type: "nvarchar(max)", nullable: true),
ScanValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsForced = table.Column<bool>(type: "bit", nullable: false),
CodArticolo = table.Column<string>(type: "nvarchar(max)", nullable: true),
Lotto = table.Column<string>(type: "nvarchar(max)", nullable: true),
RifExt = table.Column<string>(type: "nvarchar(max)", nullable: true),
Qty = table.Column<decimal>(type: "decimal(18,6)", nullable: false),
Note = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsKnown = table.Column<bool>(type: "bit", nullable: false),
IsUnique = table.Column<bool>(type: "bit", nullable: false),
InveSessID = table.Column<int>(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");
}
}
}
@@ -0,0 +1,118 @@
// <auto-generated />
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<int>("InveSessID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("InveSessID"), 1L, 1);
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DtEnd")
.HasColumnType("datetime2");
b.Property<DateTime>("DtStart")
.HasColumnType("datetime2");
b.Property<bool>("Transferred")
.HasColumnType("bit");
b.Property<string>("UserCrea")
.HasColumnType("nvarchar(max)");
b.HasKey("InveSessID");
b.ToTable("InveSess");
});
modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b =>
{
b.Property<int>("ScanID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ScanID"), 1L, 1);
b.Property<string>("CodArticolo")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DtScan")
.HasColumnType("datetime2");
b.Property<int>("InveSessID")
.HasColumnType("int");
b.Property<bool>("IsForced")
.HasColumnType("bit");
b.Property<bool>("IsKnown")
.HasColumnType("bit");
b.Property<bool>("IsUnique")
.HasColumnType("bit");
b.Property<string>("Lotto")
.HasColumnType("nvarchar(max)");
b.Property<string>("Note")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Qty")
.HasColumnType("decimal(18,2)");
b.Property<string>("RifExt")
.HasColumnType("nvarchar(max)");
b.Property<string>("ScanValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("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
}
}
}
+86
View File
@@ -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
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
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
/// <summary>
/// Indispensabile x prima generazione migrations EFCore
/// </summary>
[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<MoonPro_InveContext> options) : base(options)
{
}
#endregion Public Constructors
#region Public Properties
public virtual DbSet<InventorySessionModel> DbInveSess { get; set; }
public virtual DbSet<ScanDataModel> 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
}
}
+1 -1
View File
@@ -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"
},