I have read all post related to this and i've tried them all but not results.
Im using fluent api to map my models to the database. But when im query i get this Error:
Method not found:
'System.Data.Entity.ModelConfiguration.Configuration.DecimalPropertyConfiguration
System.Data.Entity.ModelConfiguration.Configuration.DecimalPropertyConfiguration.HasDatabaseGeneratedOption(System.Nullable`1<System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption>)'.
My model look like this:
ToTable("table_name");
HasKey(x => x.CounterId)//this property IS NOT NULLABLE
.Property(x => x.CounterId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
.HasColumnName("dbCounter_Id")
.HasPrecision(10, 0)
.IsRequired();
Property(x => x.HouseId)
.HasColumnName("dbHouseId");
Property(x => x.ApplicationId)
.HasColumnName("dbApplication_id");
For some reason .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
is giving me this error so when i quit it:
HasKey(x => x.CounterId)
.Property(x => x.PageId)
.HasColumnName("dbCounter_Id")
.HasPrecision(10, 0)
.IsRequired();
I get not error but as im lucky as hell, when im trying to add a record to that table i get insert identity exception. I cant neither added nor quit it the HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
method.
Important: The key CounterId
is not type INTEGER, is DECIMAL(10,0) instead. Could that be the problem here? I cannot change the datatype of the column since there are a lot of app in production that will be affect in the worst way.
Hope i can get any help.