Continuo migrazione oggetti EF6 --> EFCore primi 4 modelli

This commit is contained in:
Samuele Locatelli
2021-12-02 15:31:39 +01:00
parent 3460d579a0
commit 0eb990325d
9 changed files with 131 additions and 83 deletions
+18 -6
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
@@ -17,16 +18,27 @@ namespace SHERPA.BBM.CORE.DbModels
{
public BasketsModel()
{
Negotiations = new HashSet<NegotiationsModel>();
NegotNav = new HashSet<NegotiationsModel>();
}
[Key, Column("BasketId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int BasketId { get; set; }
public string CodBasket { get; set; }
public DateTime DataIns { get; set; }
public string Descript { get; set; }
public int CompanyId { get; set; }
[Column("CompanyId")]
public int CompanyId { get; set; } = 1;
[Column("CodBasket"), MaxLength(50)]
public string CodBasket { get; set; } = "BBM.0000.0000";
[Column("DataIns")]
public DateTime DataIns { get; set; } = DateTime.Now;
[Column("Descript"), MaxLength(250)]
public string Descript { get; set; } = "";
[ForeignKey("CompanyId")]
public virtual CompanyModel Company { get; set; }
public virtual ICollection<NegotiationsModel> Negotiations { get; set; }
public virtual ICollection<NegotiationsModel> NegotNav { get; set; }
}
}
+6 -2
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
@@ -20,9 +21,12 @@ namespace SHERPA.BBM.CORE.DbModels
Baskets = new HashSet<BasketsModel>();
}
[Key, Column("CompanyId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CompanyId { get; set; }
public string CodCompany { get; set; }
public string Descript { get; set; }
[Column("CodCompany"), MaxLength(50)]
public string CodCompany { get; set; } = "";
[Column("Descript"), MaxLength(250)]
public string Descript { get; set; } = "";
public virtual ICollection<BasketsModel> Baskets { get; set; }
}
+10 -4
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
@@ -20,11 +21,16 @@ namespace SHERPA.BBM.CORE.DbModels
Negotiations = new HashSet<NegotiationsModel>();
}
[Key, Column("CustomerId", Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CustomerId { get; set; }
public string RagSoc { get; set; }
public string Cf { get; set; }
public string Pi { get; set; }
public string Descript { get; set; }
[Column("RagSoc"), MaxLength(250)]
public string RagSoc { get; set; } = "";
[Column("CF"), MaxLength(50)]
public string CF { get; set; } = "";
[Column("PI"), MaxLength(50)]
public string PI { get; set; } = "";
[Column("Descript"), MaxLength(250)]
public string Descript { get; set; } = "";
public virtual ICollection<NegotiationsModel> Negotiations { get; set; }
}
+38 -14
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
@@ -17,24 +18,47 @@ namespace SHERPA.BBM.CORE.DbModels
{
public DocsModel()
{
Fatt2Docs = new HashSet<Fatt2DocModel>();
Resources = new HashSet<ResourcesModel>();
FattNav = new HashSet<Fatt2DocModel>();
ResNav = new HashSet<ResourcesModel>();
}
[Key, Column("DocId", Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int DocId { get; set; }
public string CodDoc { get; set; }
public int NegotiationId { get; set; }
public string Descript { get; set; }
public int NumDoc { get; set; }
public BbmDocType DocType { get; set; } = BbmDocType.Quotazione;
public DateTime DataIns { get; set; }
public bool IsActive { get; set; }
public string Note { get; set; }
public bool IsDraft { get; set; }
public int Anno { get; set; }
[Column("CodDoc"), MaxLength(50)]
public string CodDoc { get; set; } = "EGW.D.0000.0000.00";
[Column("Anno")]
public int Anno { get; set; } = DateTime.Today.Year;
[Column("NegotiationId")]
public int NegotiationId { get; set; }
[Column("Descript"), MaxLength(250)]
public string Descript { get; set; } = "";
[Column("NumDoc")]
public int NumDoc { get; set; } = 0;
[Column("DocType")]
public BbmDocType DocType { get; set; } = BbmDocType.Quotazione;
[Column("DataIns")]
public DateTime DataIns { get; set; } = DateTime.Now;
[Column("IsActive")]
public bool IsActive { get; set; } = false;
[Column("IsDraft")]
public bool IsDraft { get; set; } = false;
[Column("Note"), MaxLength(500)]
public string Note { get; set; } = "";
[ForeignKey("NegotiationId")]
public virtual NegotiationsModel Negotiation { get; set; }
public virtual ICollection<Fatt2DocModel> Fatt2Docs { get; set; }
public virtual ICollection<ResourcesModel> Resources { get; set; }
public virtual ICollection<Fatt2DocModel> FattNav { get; set; }
public virtual ICollection<ResourcesModel> ResNav { get; set; }
}
}
+45 -45
View File
@@ -72,65 +72,65 @@ namespace SHERPA.BBM.CORE
{
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
modelBuilder.Entity<BasketsModel>(entity =>
{
entity.HasIndex(e => e.CompanyId, "IX_CompanyId");
//modelBuilder.Entity<BasketsModel>(entity =>
//{
// entity.HasIndex(e => e.CompanyId, "IX_CompanyId");
entity.Property(e => e.CodBasket).HasMaxLength(50);
// entity.Property(e => e.CodBasket).HasMaxLength(50);
entity.Property(e => e.DataIns).HasColumnType("datetime");
// entity.Property(e => e.DataIns).HasColumnType("datetime");
entity.Property(e => e.Descript).HasMaxLength(250);
// entity.Property(e => e.Descript).HasMaxLength(250);
entity.HasOne(d => d.Company)
.WithMany(p => p.Baskets)
.HasForeignKey(d => d.CompanyId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_dbo.Baskets_dbo.Company_CompanyId");
});
// entity.HasOne(d => d.Company)
// .WithMany(p => p.Baskets)
// .HasForeignKey(d => d.CompanyId)
// .OnDelete(DeleteBehavior.ClientSetNull)
// .HasConstraintName("FK_dbo.Baskets_dbo.Company_CompanyId");
//});
modelBuilder.Entity<CompanyModel>(entity =>
{
entity.ToTable("Company");
//modelBuilder.Entity<CompanyModel>(entity =>
//{
// entity.ToTable("Company");
entity.Property(e => e.CodCompany).HasMaxLength(50);
// entity.Property(e => e.CodCompany).HasMaxLength(50);
entity.Property(e => e.Descript).HasMaxLength(250);
});
// entity.Property(e => e.Descript).HasMaxLength(250);
//});
modelBuilder.Entity<CustomersModel>(entity =>
{
entity.Property(e => e.Cf)
.HasMaxLength(50)
.HasColumnName("CF");
//modelBuilder.Entity<CustomersModel>(entity =>
//{
// entity.Property(e => e.CF)
// .HasMaxLength(50)
// .HasColumnName("CF");
entity.Property(e => e.Descript).HasMaxLength(250);
// entity.Property(e => e.Descript).HasMaxLength(250);
entity.Property(e => e.Pi)
.HasMaxLength(50)
.HasColumnName("PI");
// entity.Property(e => e.PI)
// .HasMaxLength(50)
// .HasColumnName("PI");
entity.Property(e => e.RagSoc).HasMaxLength(250);
});
// entity.Property(e => e.RagSoc).HasMaxLength(250);
//});
modelBuilder.Entity<DocsModel>(entity =>
{
entity.HasIndex(e => e.NegotiationId, "IX_NegotiationId")
.HasFillFactor((byte)100);
//modelBuilder.Entity<DocsModel>(entity =>
//{
// entity.HasIndex(e => e.NegotiationId, "IX_NegotiationId")
// .HasFillFactor((byte)100);
entity.Property(e => e.CodDoc).HasMaxLength(50);
// entity.Property(e => e.CodDoc).HasMaxLength(50);
entity.Property(e => e.DataIns).HasColumnType("datetime");
// entity.Property(e => e.DataIns).HasColumnType("datetime");
entity.Property(e => e.Descript).HasMaxLength(250);
// entity.Property(e => e.Descript).HasMaxLength(250);
entity.Property(e => e.Note).HasMaxLength(500);
// entity.Property(e => e.Note).HasMaxLength(500);
entity.HasOne(d => d.Negotiation)
.WithMany(p => p.Docs)
.HasForeignKey(d => d.NegotiationId)
.HasConstraintName("FK_dbo.Docs_dbo.Negotiations_NegotiationId");
});
// entity.HasOne(d => d.Negotiation)
// .WithMany(p => p.Docs)
// .HasForeignKey(d => d.NegotiationId)
// .HasConstraintName("FK_dbo.Docs_dbo.Negotiations_NegotiationId");
//});
modelBuilder.Entity<Fatt2DocModel>(entity =>
{
@@ -149,7 +149,7 @@ namespace SHERPA.BBM.CORE
entity.Property(e => e.Incassato).HasColumnType("decimal(18, 4)");
entity.HasOne(d => d.Document)
.WithMany(p => p.Fatt2Docs)
.WithMany(p => p.FattNav)
.HasForeignKey(d => d.DocId)
.HasConstraintName("FK_dbo.Fatt2Doc_dbo.Docs_DocId");
});
@@ -204,7 +204,7 @@ namespace SHERPA.BBM.CORE
entity.Property(e => e.Descript).HasMaxLength(250);
entity.HasOne(d => d.Basket)
.WithMany(p => p.Negotiations)
.WithMany(p => p.NegotNav)
.HasForeignKey(d => d.BasketId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_dbo.Negotiations_dbo.Baskets_BasketId");
@@ -225,7 +225,7 @@ namespace SHERPA.BBM.CORE
.HasFillFactor((byte)100);
entity.HasOne(d => d.Document)
.WithMany(p => p.Resources)
.WithMany(p => p.ResNav)
.HasForeignKey(d => d.DocId)
.HasConstraintName("FK_dbo.Resources_dbo.Docs_DocId");
+3 -3
View File
@@ -17,12 +17,12 @@ namespace SHERPA.BBM.DatabaseModels
{
#region Public Properties
[Column("CodCompany", Order = 1), MaxLength(50)]
public string CodCompany { get; set; } = "";
[Key, Column("CompanyId", Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CompanyId { get; set; }
[Column("CodCompany", Order = 1), MaxLength(50)]
public string CodCompany { get; set; } = "";
[Column("Descript", Order = 2), MaxLength(250)]
public string Descript { get; set; } = "";
+9 -7
View File
@@ -17,21 +17,23 @@ namespace SHERPA.BBM.DatabaseModels
{
#region Public Properties
[Column("CF", Order = 2), MaxLength(50)]
public string CF { get; set; } = "";
[Key, Column("CustomerId", Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CustomerId { get; set; }
[Column("RagSoc", Order = 1), MaxLength(250)]
public string RagSoc { get; set; } = "";
[Column("CF", Order = 2), MaxLength(50)]
public string CF { get; set; } = "";
[Column("Descript", Order = 4), MaxLength(250)]
public string Descript { get; set; } = "";
[Column("PI", Order = 3), MaxLength(50)]
public string PI { get; set; } = "";
[Column("Descript", Order = 4), MaxLength(250)]
public string Descript { get; set; } = "";
[Column("RagSoc", Order = 1), MaxLength(250)]
public string RagSoc { get; set; } = "";
#endregion Public Properties
}
}
+1 -1
View File
@@ -54,9 +54,9 @@ namespace SHERPA.BBM.DatabaseModels
[ForeignKey("NegotiationId")]
public virtual NegotiationsModel Negotiation { get; set; }
public virtual ICollection<ResourcesModel> ResNav { get; set; }
public virtual ICollection<Fatt2DocModel> FattNav { get; set; }
public virtual ICollection<ResourcesModel> ResNav { get; set; }
//[Column("DocPath", Order = 8), MaxLength(500)]
+1 -1
View File
@@ -10,7 +10,7 @@
<IISExpressSSLPort />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>