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 665295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:41:33+00:00 2026-05-13T23:41:33+00:00

I have a little / weird behaviour here and Im looking over internet and

  • 0

I have a little / weird behaviour here and Im looking over internet and SO and I didn’t find a response.

I have to admit that this is my first time using databases, I know how to use them with SQL but never used it actually.

Anyway, I have a problem with my app inserting data, I just created a very simple project for testing that and no solution yet.

I have an example database with Sql Server

Id – int (identity primary key)
Name – nchar(10) (not null)

The table is called "Person", simple as pie.

I have this:

static void Main(string[] args)
{
    var db = new ExampleDBDataContext {Log = Console.Out};

    var jesus = new Person {Name = "Jesus"};

    db.Persons.InsertOnSubmit(jesus);
    db.SubmitChanges();

    var query = from person in db.Persons select person;

    foreach (var p in query)
    {
        Console.WriteLine(p.Name);
    }
}

As you can see, nothing extrange.

It show Jesus in the console. But if you see the table data, there is no data, just empty. I comment the object creation and insertion and the foreach doesn’t print a thing (normal, there is no data in the database)

The weird thing is that I created a row in the database manually and the Id was 2 and no 1 (Was the linq really playing with the database but it didn’t create the row?)

There is the log:

INSERT INTO [dbo].Person

VALUES (@p0)

SELECT CONVERT(Int,SCOPE_IDENTITY()) AS [value]

— @p0: Input NChar (Size = 10; Prec = 0; Scale = 0) [Jesus]

— Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.30729.4926

SELECT [t0].[Id], [t0].[Name]
FROM [dbo].[Person] AS [t0]

— Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.30729.4926

I am really confused, All the blogs / books use this kind of snippet to insert an element to a database.

Thank you for helping.

  • 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-05-13T23:41:33+00:00Added an answer on May 13, 2026 at 11:41 pm

    First; do you have a TransactionScope that spans this, that you haven’t committed.

    However, more liktely: is this a database file that you are deploying with the system (rather than a separate database server)? If so, every time you hit “build” etc, it copies the version from your solution folder into the build output (bin/debug or bin/release).

    Look in the build output copy; see if that has been updated.

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

Sidebar

Related Questions

Hey guys, this question might be a little weird worded but I was looking
I am having a weird error when using Omniauth. This appears to have little
This is a little weird. I have the following scenario: A page containing a
So I have this weird looking problem: my very basic program generates an error
I have little question about how web browser retrieve webpage? I know this User
I have very little experience in web development, so this may be a very
This morning I stumbled over a weird issue in Visual Studio's Windows Forms designer.
I have run into a rather weird little problem. In the following code I
The question is a little bit weird, but that's what I need ;) Usually,
Well!! My question is little weird .. I have created an chat channel which

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.