1
I have a table mapping (Entity Framework Core 2.0) in which the Id field needs to be Autoincrement.
The problem is that Postgresql is starting with high value and often jumps to very high sequences, like, increasing from 10 to 10.
What am I doing wrong? I would like it to be started with 0 and be self-administered.
(
public class ProfissaoMap : IEntityTypeConfiguration<Profissao>
{
public void Configure(EntityTypeBuilder<Profissao> builder)
{
builder.ToTable("Profissao");
builder.HasKey(p => new {p.Id});
builder.Property(p => p.Id)
.ForNpgsqlUseSequenceHiLo()
.IsRequired();
builder.Property(p => p.Id)
.HasColumnName("ProfissaoId")
.HasColumnType("integer")
.IsRequired();
builder.Property(p => p.Descricao)
.HasColumnName("Descricao")
.HasColumnType("character varying(50)")
.IsRequired();
builder.Property(p => p.PadraoSistema)
.HasColumnName("PadraoSistema")
.HasColumnType("boolean");
}
}
Why do you have this
builder.HasKey(p => new {p.Id});
? Shouldn’t bebuilder.HasKey(p => p.Id);
? It must have no relation to the problem described, but I was surprised.– Jéf Bueno
I once followed an example on the net that taught how to use new... It works both ways @hkotsubo rsrsssrs
– Master JR