your databse does not allow null values for the column AssistentResponsibleName remove the question mark from property definition like
public string AssistantResponsibleName { get; set; }
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
Here is my entity;
public class OrderDetail
{
public int Id { get; set; }
[Required]
[MaxLength(100)]
public string ProductCode { get; set; }
[Required]
[MaxLength(250)]
public string ProductName { get; set; }
[Required]
public int Quantity { get; set; }
[Required]
public double BuyUnitPrice { get; set; }
public double CostRatio { get; set; }
public double UnitCost { get; set; }
public double TotalBuyPrice { get; set; }
public double SellUnitPrice { get; set; }
public double TotalSellPrice { get; set; }
[MaxLength(150)]
public string ShippingNumber { get; set; }
public string Status { get; set; }
[MaxLength(150)]
public string TrackingNumber { get; set; }
[MaxLength(400)]
public string Description { get; set; }
public string Currency { get; set; }
public string CustomerStockCode { get; set; }
public string CustomerOrderNumber { get; set; }
public int IsActive { get; set; }
public double TotalUnitCost { get; set; }
public int OrderId { get; set; }
public int VendorId { get; set; }
public Order Order { get; set; }
public Vendor Vendor { get; set; }
}
Here is migration:
modelBuilder.Entity("IMS.CoreBusiness.OrderDetail", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("BuyUnitPrice")
.HasColumnType("float");
b.Property<double>("CostRatio")
.HasColumnType("float");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CustomerOrderNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CustomerStockCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<int>("IsActive")
.HasColumnType("int");
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>("Quantity")
.HasColumnType("int");
b.Property<double>("SellUnitPrice")
.HasColumnType("float");
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<double>("TotalUnitCost")
.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");
});
Why are some of the properties IsRequired even though they are not marked Required in the entity?
your databse does not allow null values for the column AssistentResponsibleName remove the question mark from property definition like
public string AssistantResponsibleName { get; set; }
Just need to remove this line "enable" on .csproj file
<Nullable>enable</Nullable>