Hello,
There is an inconsistency when editing relationships between entities. I also deleted a migration, How can I fix this inconsistency? I expect your support.
Error: Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'VendorId'.
Invalid column name 'VendorId'.
Here is the snapshot:
using System;
using IMS.Plugins.EFCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace IMS.Plugins.EFCore.Migrations
{
[DbContext(typeof(IMSContext))]
partial class IMSContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("IMS.CoreBusiness.Customer", b =>
{
b.Property<int>("CustomerId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CustomerId"), 1L, 1);
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AssistantResponsibleName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("DeliveryAddress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MainResponsibleName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("TaxAdministration")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TaxNumber")
.HasColumnType("int");
b.HasKey("CustomerId");
b.ToTable("Customers");
});
modelBuilder.Entity("IMS.CoreBusiness.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("CustomerName")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.Property<string>("DoneBy")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime>("OrderDateTime")
.HasColumnType("datetime2");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("IMS.CoreBusiness.OrderDetail", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("BuyQuantity")
.HasColumnType("int");
b.Property<double>("CostRatio")
.HasColumnType("float");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<string>("ProductCode")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("ProductName")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.Property<int>("SellQuantity")
.HasColumnType("int");
b.Property<string>("ShippingNumber")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("TotalBuyPrice")
.HasColumnType("float");
b.Property<double>("TotalSellPrice")
.HasColumnType("float");
b.Property<string>("TrackingNumber")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<double>("UnitCost")
.HasColumnType("float");
b.Property<int>("VendorId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("VendorId");
b.ToTable("OrdersDetail");
});
modelBuilder.Entity("IMS.CoreBusiness.Vendor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AssistantResponsibleName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MainResponsibleName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Vendors");
});
modelBuilder.Entity("IMS.CoreBusiness.OrderDetail", b =>
{
b.HasOne("IMS.CoreBusiness.Order", "Order")
.WithMany("OrderDetails")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IMS.CoreBusiness.Vendor", "Vendor")
.WithMany("OrderDetails")
.HasForeignKey("VendorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Vendor");
});
modelBuilder.Entity("IMS.CoreBusiness.Order", b =>
{
b.Navigation("OrderDetails");
});
modelBuilder.Entity("IMS.CoreBusiness.Vendor", b =>
{
b.Navigation("OrderDetails");
});
#pragma warning restore 612, 618
}
}
}