Home ORMLite error on insert with autoincrement key
Reply: 0

ORMLite error on insert with autoincrement key

user959 Published in June 24, 2018, 3:08 am

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.401028 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO