Fix migration (iniziale9 x nuova tab

This commit is contained in:
Samuele Locatelli
2024-02-12 15:13:58 +01:00
parent 5655c5e558
commit c7745f77b5
6 changed files with 1889 additions and 23 deletions
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHERPA.BBM.CORE.DbModels
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Tabella dei tipi di Items/Risorsa (upgrade da enum)
/// </summary>
[Table("ResType")]
public partial class ItemResTypeModel
{
[Key, Column("ResTypeId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ResTypeId { get; set; }
[Column("Name"), MaxLength(250)]
public string Name { get; set; } = "ND";
}
}
+51
View File
@@ -0,0 +1,51 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SHERPA.BBM.CORE.DbModels;
namespace SHERPA.BBM.CORE
{
public class ItemResTypeConfig : IEntityTypeConfiguration<ItemResTypeModel>
{
#region Public Methods
public void Configure(EntityTypeBuilder<ItemResTypeModel> builder)
{
//// sistemo identity
//builder.Property(prop => prop.NegotTypeId)
// .UseIdentityColumn(1, 1);
builder.Property(prop => prop.ResTypeId)
.ValueGeneratedOnAdd();
// Default seeded users
builder.HasData(
seedRecord(-1,"ND"),
seedRecord(1, "HR"),
seedRecord(2, "License"),
seedRecord(3, "HW"),
seedRecord(4, "Service"),
seedRecord(5, "Lic_CMS"),
seedRecord(6, "Lic_ESSETRE"),
seedRecord(7, "Lic_MULTIAX"),
seedRecord(8, "Lic_OMAG"),
seedRecord(9, "Lic_SAOMAD"),
seedRecord(10, "Lic_MES")
);
}
#endregion Public Methods
#region Protected Methods
protected ItemResTypeModel seedRecord(int id, string name)
{
var newRec = new ItemResTypeModel()
{
ResTypeId = id,
Name = name };
return newRec;
}
#endregion Protected Methods
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SHERPA.BBM.CORE.Migrations
{
public partial class AddItemResTypeModel : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ResType",
columns: table => new
{
ResTypeId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ResType", x => x.ResTypeId);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ResType");
}
}
}
@@ -56,7 +56,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("OrdId");
b.ToTable("AccMov", (string)null);
b.ToTable("AccMov");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.BasketsModel", b =>
@@ -102,7 +102,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("CompanyId");
b.ToTable("Baskets", (string)null);
b.ToTable("Baskets");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.BillingExtModel", b =>
@@ -187,7 +187,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("CustExtId");
b.ToTable("BillingExt", (string)null);
b.ToTable("BillingExt");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.BillingModel", b =>
@@ -237,7 +237,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("OrdId");
b.ToTable("Billing", (string)null);
b.ToTable("Billing");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.CompanyModel", b =>
@@ -261,7 +261,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("CompanyId");
b.ToTable("Company", (string)null);
b.ToTable("Company");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.CustDecodModel", b =>
@@ -293,7 +293,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("CustExtId");
b.ToTable("CustDecod", (string)null);
b.ToTable("CustDecod");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.CustomersModel", b =>
@@ -328,7 +328,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("CustomerId");
b.ToTable("Customers", (string)null);
b.ToTable("Customers");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.DocsModel", b =>
@@ -396,7 +396,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("NegotiationId");
b.ToTable("Docs", (string)null);
b.ToTable("Docs");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.Fatt2DocModel", b =>
@@ -440,7 +440,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("DocId");
b.ToTable("Fatt2Doc", (string)null);
b.ToTable("Fatt2Doc");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.FluxCountersModel", b =>
@@ -456,7 +456,26 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("CodCounter");
b.ToTable("FluxCounters", (string)null);
b.ToTable("FluxCounters");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.ItemResTypeModel", b =>
{
b.Property<int>("ResTypeId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("ResTypeId");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ResTypeId"), 1L, 1);
b.Property<string>("Name")
.HasMaxLength(250)
.HasColumnType("nvarchar(250)")
.HasColumnName("Name");
b.HasKey("ResTypeId");
b.ToTable("ResType");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.ItemsModel", b =>
@@ -493,7 +512,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("ItemId");
b.ToTable("Items", (string)null);
b.ToTable("Items");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.MTypeModel", b =>
@@ -510,7 +529,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("CodMType");
b.ToTable("MTypeModel", (string)null);
b.ToTable("MTypeModel");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.NegotiationsModel", b =>
@@ -558,7 +577,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("CustomerId");
b.ToTable("Negotiations", (string)null);
b.ToTable("Negotiations");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.NegotTypeModel", b =>
@@ -590,7 +609,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("NegotTypeId");
b.ToTable("NegotType", (string)null);
b.ToTable("NegotType");
b.HasData(
new
@@ -703,7 +722,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("NegotiationId");
b.ToTable("Orders", (string)null);
b.ToTable("Orders");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.OrderResModel", b =>
@@ -757,7 +776,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("OrdId");
b.ToTable("OrderRes", (string)null);
b.ToTable("OrderRes");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.ResourcesModel", b =>
@@ -811,7 +830,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("ItemId");
b.ToTable("Resources", (string)null);
b.ToTable("Resources");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.TagItemModel", b =>
@@ -829,7 +848,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasIndex("TagId");
b.ToTable("Tag2Item", (string)null);
b.ToTable("Tag2Item");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.TagModel", b =>
@@ -857,7 +876,7 @@ namespace SHERPA.BBM.CORE.Migrations
b.HasKey("TagId");
b.ToTable("Tags", (string)null);
b.ToTable("Tags");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.vBasketsDataModel", b =>
@@ -1148,11 +1167,131 @@ namespace SHERPA.BBM.CORE.Migrations
.HasColumnType("decimal(18,6)")
.HasColumnName("Ordinato");
b.Property<string>("RagSoc")
.HasColumnType("nvarchar(max)")
.HasColumnName("RagSoc");
b.HasKey("NegotiationId");
b.ToView("v_NegotData");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.vOrderDataModel", b =>
{
b.Property<int>("OrdId")
.HasColumnType("int")
.HasColumnName("OrdId")
.HasColumnOrder(0);
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("OrdId"), 1L, 1);
b.Property<decimal>("AmountTot")
.HasPrecision(18, 6)
.HasColumnType("decimal(18,6)")
.HasColumnName("AmountTot");
b.Property<string>("BaskDescript")
.HasColumnType("nvarchar(max)")
.HasColumnName("BaskDescript");
b.Property<int>("BasketId")
.HasColumnType("int")
.HasColumnName("BasketId");
b.Property<decimal>("BillTot")
.HasPrecision(18, 6)
.HasColumnType("decimal(18,6)")
.HasColumnName("BillTot");
b.Property<string>("CodBasket")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("CodBasket");
b.Property<string>("CodDoc")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("CodDoc");
b.Property<string>("CodMType")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("CodMType");
b.Property<string>("CodNegotiation")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("CodNegotiation");
b.Property<int>("CustomerId")
.HasColumnType("int")
.HasColumnName("CustomerId");
b.Property<DateTime>("DateIns")
.HasColumnType("datetime2")
.HasColumnName("DateIns");
b.Property<string>("Descript")
.HasMaxLength(250)
.HasColumnType("nvarchar(250)")
.HasColumnName("Descript");
b.Property<int>("DocId")
.HasColumnType("int")
.HasColumnName("DocId");
b.Property<bool>("HasBill")
.HasColumnType("bit")
.HasColumnName("HasBill");
b.Property<bool>("MovOpen")
.HasColumnType("bit")
.HasColumnName("MovOpen");
b.Property<string>("NegotDescript")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)")
.HasColumnName("NegotDescript");
b.Property<int>("NegotiationId")
.HasColumnType("int")
.HasColumnName("NegotiationId");
b.Property<string>("Note")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)")
.HasColumnName("Note");
b.Property<int>("Num")
.HasColumnType("int")
.HasColumnName("Num");
b.Property<int>("OrdStatus")
.HasColumnType("int")
.HasColumnName("OrdStatus");
b.Property<int>("OrdType")
.HasColumnType("int")
.HasColumnName("OrdType");
b.Property<decimal>("PaidTot")
.HasPrecision(18, 6)
.HasColumnType("decimal(18,6)")
.HasColumnName("PaidTot");
b.Property<string>("RagSoc")
.HasColumnType("nvarchar(max)")
.HasColumnName("RagSoc");
b.Property<int>("YearRef")
.HasColumnType("int")
.HasColumnName("YearRef");
b.HasKey("OrdId");
b.ToView("v_OrderData");
});
modelBuilder.Entity("SHERPA.BBM.CORE.DbModels.vTrendDataModel", b =>
{
b.Property<int>("YearRef")
+2 -4
View File
@@ -64,6 +64,7 @@ namespace SHERPA.BBM.CORE
public virtual DbSet<vYearDataModel> DbSetYearData { get; set; } = null!;
public virtual DbSet<vDocsDataModel> DbSetDocsData { get; set; } = null!;
public virtual DbSet<vOrderDataModel> DbSetOrderData { get; set; } = null!;
public virtual DbSet<ItemResTypeModel> DbSetItemResType { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -81,9 +82,6 @@ namespace SHERPA.BBM.CORE
// PROD
//optionsBuilder.UseSqlServer("Data Source=W2019-SQL-STEAM;Initial Catalog=SHERPA.BBM;Trusted_Connection=True;");
// DEV 2016
//optionsBuilder.UseSqlServer("Data Source=SQL2016DEV;Initial Catalog=SHERPA.BBM;Trusted_Connection=True;");
}
}
}
@@ -321,7 +319,7 @@ namespace SHERPA.BBM.CORE
if (!disableMigrate)
{
modelBuilder.ApplyConfiguration(new NegotConfig());
//modelBuilder.ApplyConfiguration(new ItemResTypeConfig());
}
OnModelCreatingPartial(modelBuilder);