DbTariffRow: removed id

This commit is contained in:
pavelbannov 2022-09-23 15:26:26 +03:00
parent 2a090bea6c
commit 4f3831ac16
7 changed files with 19 additions and 43 deletions

View File

@ -26,13 +26,17 @@
namespace ASC.Core.Common.EF; namespace ASC.Core.Common.EF;
public class DbTariffRow public class DbTariffRow : BaseEntity
{ {
public int Id { get; set; }
public int TariffId { get; set; } public int TariffId { get; set; }
public int Quota { get; set; } public int Quota { get; set; }
public int Quantity { get; set; } public int Quantity { get; set; }
public int Tenant { get; set; } public int Tenant { get; set; }
public override object[] GetKeys()
{
return new object[] { Tenant, TariffId, Quota };
}
} }
public static class DbTariffRowExtension public static class DbTariffRowExtension
{ {
@ -49,12 +53,9 @@ public static class DbTariffRowExtension
{ {
entity.ToTable("tenants_tariffrow"); entity.ToTable("tenants_tariffrow");
entity.HasKey(e => e.Id) entity.HasKey(e => new { e.Tenant, e.TariffId, e.Quota })
.HasName("PRIMARY"); .HasName("PRIMARY");
entity.Property(e => e.Id)
.HasColumnName("id");
entity.Property(e => e.TariffId) entity.Property(e => e.TariffId)
.HasColumnName("tariff_id") .HasColumnName("tariff_id")
.HasColumnType("int"); .HasColumnType("int");

View File

@ -1,5 +1,7 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using ASC.Core.Billing;
using ASC.Core.Common.EF; using ASC.Core.Common.EF;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
@ -188,11 +190,6 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb
modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b =>
{ {
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("id");
b.Property<int>("Quantity") b.Property<int>("Quantity")
.HasColumnType("int") .HasColumnType("int")
.HasColumnName("quantity"); .HasColumnName("quantity");
@ -209,7 +206,7 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb
.HasColumnType("int") .HasColumnType("int")
.HasColumnName("tenant"); .HasColumnName("tenant");
b.HasKey("Id") b.HasKey("Tenant", "TariffId", "Quota")
.HasName("PRIMARY"); .HasName("PRIMARY");
b.ToTable("tenants_tariffrow", (string)null); b.ToTable("tenants_tariffrow", (string)null);

View File

@ -24,7 +24,6 @@
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
@ -74,8 +73,6 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb
name: "tenants_tariffrow", name: "tenants_tariffrow",
columns: table => new columns: table => new
{ {
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
tariff_id = table.Column<int>(type: "int", nullable: false), tariff_id = table.Column<int>(type: "int", nullable: false),
quota = table.Column<int>(type: "int", nullable: false), quota = table.Column<int>(type: "int", nullable: false),
quantity = table.Column<int>(type: "int", nullable: false), quantity = table.Column<int>(type: "int", nullable: false),
@ -83,7 +80,7 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PRIMARY", x => x.id); table.PrimaryKey("PRIMARY", x => new { x.tenant, x.tariff_id, x.quota });
}) })
.Annotation("MySql:CharSet", "utf8mb4"); .Annotation("MySql:CharSet", "utf8mb4");

View File

@ -177,11 +177,6 @@ namespace ASC.Migrations.MySql.Migrations
modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b =>
{ {
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("id");
b.Property<int>("Quantity") b.Property<int>("Quantity")
.HasColumnType("int") .HasColumnType("int")
.HasColumnName("quantity"); .HasColumnName("quantity");
@ -198,8 +193,8 @@ namespace ASC.Migrations.MySql.Migrations
.HasColumnType("int") .HasColumnType("int")
.HasColumnName("tenant"); .HasColumnName("tenant");
b.HasKey("Id") b.HasKey("Tenant", "TariffId", "Quota")
.HasName("PRIMARY"); .HasName("PRIMARY");
b.ToTable("tenants_tariffrow", (string)null); b.ToTable("tenants_tariffrow", (string)null);
}); });

View File

@ -185,11 +185,6 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b =>
{ {
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Quantity") b.Property<int>("Quantity")
.HasColumnType("integer"); .HasColumnType("integer");
@ -202,7 +197,7 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
b.Property<int>("Tenant") b.Property<int>("Tenant")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Tenant", "TariffId", "Quota");
b.ToTable("TariffRows"); b.ToTable("TariffRows");
}); });

View File

@ -26,8 +26,6 @@
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
namespace ASC.Migrations.PostgreSql.Migrations.CoreDb namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
@ -80,8 +78,6 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
name: "TariffRows", name: "TariffRows",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
TariffId = table.Column<int>(type: "integer", nullable: false), TariffId = table.Column<int>(type: "integer", nullable: false),
Quota = table.Column<int>(type: "integer", nullable: false), Quota = table.Column<int>(type: "integer", nullable: false),
Quantity = table.Column<int>(type: "integer", nullable: false), Quantity = table.Column<int>(type: "integer", nullable: false),
@ -89,7 +85,7 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_TariffRows", x => x.Id); table.PrimaryKey("PK_TariffRows", x => new { x.Tenant, x.TariffId, x.Quota });
}); });
migrationBuilder.UpdateData( migrationBuilder.UpdateData(

View File

@ -174,11 +174,6 @@ namespace ASC.Migrations.PostgreSql.Migrations
modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b =>
{ {
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Quantity") b.Property<int>("Quantity")
.HasColumnType("integer"); .HasColumnType("integer");
@ -191,7 +186,7 @@ namespace ASC.Migrations.PostgreSql.Migrations
b.Property<int>("Tenant") b.Property<int>("Tenant")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Tenant", "TariffId", "Quota");
b.ToTable("TariffRows"); b.ToTable("TariffRows");
}); });