I'm using Ef core Code First to generate a Database. But I'm not sure why it's creating a new column with *ID1.
Entity
public class Room : BaseEntity
{
public string Name { get; set; }
public string UniqueCode { get; set; }
public int BranchId { get; set; }
public virtual Branch Branch { get; set; }
public CommonStatus Status { get; set; }
}
Configuration
public class RoomConfiguration : IEntityTypeConfiguration<Room>
{
public void Configure(EntityTypeBuilder<Room> builder)
{
builder.Property(t => t.Name).IsRequired().HasMaxLength(10);
builder.Property(t => t.UniqueCode).IsRequired().HasMaxLength(10);
builder.HasIndex(p => p.Status);
builder.HasOne(s => s.Branch)
.WithMany()
.HasForeignKey(e => e.BranchId)
.OnDelete(DeleteBehavior.Restrict);
}
}
Migration
migrationBuilder.CreateTable(
name: "Room",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(maxLength: 10, nullable: false),
UniqueCode = table.Column<string>(maxLength: 10, nullable: false),
BranchId = table.Column<int>(nullable: false),
Status = table.Column<int>(nullable: false),
BranchId1 = table.Column<int>(nullable: true)
}
As You can sett the migration script actually has BranchId1 which I never defined. and this happening in some entity as well but not all. I just want to know why it's happening thanks