I’m a beginner and i am having this error when i use the update-data base, after the migration:
“To change the IDENTITY property of a column, the column needs to be dropped and recreated.”
And I’m not sure what to do
Here is my model:
> public class ModelTraceType
{
public string Type { get; set; }
public int Class { get; set; }
}
}
EntityConfigTraceType:
{
public class EntityConfigTraceType : IEntityTypeConfiguration<TraceType>
{
private const string TableName = "TRACE_TYPE";
public void Configure(EntityTypeBuilder<TraceType> builder)
{
builder
.ToTable(TableName);
//builder
//.HasKey(p => p.Type)
//.IsClustered();
builder
.HasKey(p => p.Id)
.IsClustered();
builder
.Property(p => p.Type)
.IsRequired();
builder
.Property(p => p.Class)
.IsRequired();
builder
builder
.Property(p => p.Id)
.IsRequired()
.ValueGeneratedOnAdd(); // Explicitly marks the Id as an auto-incrementing field
.Property(p => p.Type)
.IsRequired()
.HasMaxLength(TraceType.TypeLength);
New contributor
Carolina Elias is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1