Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8448627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:28:45+00:00 2026-06-10T10:28:45+00:00

In my application I have a model Client with int primary key Id. (model

  • 0

In my application I have a model Client with int primary key Id. (model generated from database by metalsql)

var c = new Client{Name = "jonny"};
myDbContext.Client.InsertOnSubmit(c);

This code causes an error when I add the second client, because it turns out it Id field isn’t being incremented. It just takes the default value of 0. Is there a smart way to make this autoincrement work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:28:47+00:00Added an answer on June 10, 2026 at 10:28 am

    In your current table your column ID is not set to int is identity so you need to supply it.

    var c = new Client{ID = 2,Name = "jonny"};
    myDbContext.Client.InsertOnSubmit(c);
    

    To solve this make sure your table ID column is Set to int is identity to make your code works

    var c = new Client{Name = "jonny"};
    myDbContext.Client.InsertOnSubmit(c);
    

    See this link:

    Creating A Database In Microsoft Visual Studio 2010

    Best Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a client application I have a DBIx::Class model 'Todo' that can be linked
I have one grails application.In that I have one model class named Book. From
I have a client application (WPF, C#, .net4) which uses POCO entity model connected
I have some model objects I'm using in my Java client application. Later these
in my zf application i have base model class Application_Model, which connects to db
In our ColdFusion application we have stateless model objects. All the data I want
In my application I have a custom model binder that I set to the
I am building an application that will have a model that belongs_to another model
I have a model in my rails application which is class Person < ActiveRecord::Base
I have an application where I have a Shipment model. I have created a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.