Home ORMLite error on insert with autoincrement key
Reply: 0

ORMLite error on insert with autoincrement key

user959 Published in March 19, 2018, 6:07 pm

I have the following MVC 5 Model:

public class Map {
    public int Id { get; set; }

    public String Name { get; set; }



The id attribute on the table is a primary key autoincrement.

I need the Id to perform update operations but this prevents me to insert new entries.

This update works:

var res = dbConnection.Update<Map>(map);

While this insert does not:

var res = dbConnection.Insert<Map>(map, selectIdentity: true);

I get this exception:

Cannot insert explicit valuefor identity column in table 'map' when IDENTITY_INSERT is set to OFF.

What can I do to solve this?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.349102 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO