Error when generating entity with Guid as PK

Viewed 35

I'm trying to create a PostgreSQL database with EF core and ABP framwework but when it tries to create the table I got the following error in console

[11:58:34 ERR] Failed executing DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
ALTER TABLE "AppClienti" ALTER COLUMN "Id" TYPE uuid;
ALTER TABLE "AppClienti" ALTER COLUMN "Id"
DROP IDENTITY;

and this is the visual studio error in Debug

Npgsql.PostgresException: '22023: identity column type must be smallint, integer, or bigint'

My class is defined as

 public partial class Cliente : AggregateRoot<Guid>
  {
    [StringLength(255)]
    public string RagioneSociale { get; set; }
    public double? OrdineLimite { get; set; }
    public float? Sconto1 { get; set; }
}

In the DbContext.OnModelCreating it's defined as

 builder.Entity<Cliente>(b =>
        {
            b.ToTable(IlDiamanteConsts.DbTablePrefix + "Clienti", IlDiamanteConsts.DbSchema);
            b.ConfigureByConvention(); //auto-configure for the base class props
           ...properties mapping...
        });

No specific mapping is defined for the Id column since I think it should be handled by .ConfigureByConvention.

Any suggestion? I know that for this particular case I can just have a newid as value and just set it as Key.. but I don't know where to set it.

Thanks

#UPDATE #1

It was my fault, I had a first migration step where I was defining it as int, then when it tries to alter, that error comes up. I've recreated migration scripts from zero and now it works like a charm.

0 Answers
Related