[RESOLVED]How to find why unique ID is not Posting to the database

I am using a auto-generated id for my Job Class. It is making it to the apiController and it is not showing any errors after the Post. however it is not Posting in the database, It is still using the auto increment id. I am using the same setup for other
classes and it works fine. How do i find out what is happening.

https://drive.google.com/file/d/0B-zrEeoOpFm4Ykc0SmRJQVJWTDQ/view?usp=sharing

Hi texas697,

If you are using the auto increment column, it will use the increment id, it will ignore the value that you set.

Best Regards

Starain

when i change it to this

 public class Job
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.None)]
        public Int64? JobId { get; set; }
        public int? JobNumber { get; set; }

I am getting a error saying it isnt set to off

  1. ExceptionMessage"Cannot insert
    explicit value for identity column in table ‘Jobs’ when IDENTITY_INSERT is set to OFF."

But it is set to off?

Then i look at my database and it shows this 

that Identity Specification has these setting

Is identity Yes

Identity Increment 1

Identity Seed 1

texas697

Then i look at my database and it shows this 

that Identity Specification has these setting

Is identity Yes

Identity Increment 1

Identity Seed 1

This is the one you should be setting off. Make "Is identity" = No. You’ll notice that Identity Increment and Identity Seed would also be disabled.

Leave a Reply