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

  • Home
  • SEARCH
  • 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 8338271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:32:27+00:00 2026-06-09T04:32:27+00:00

I have a very simple windows form project with Entity Framework. Simply I draged

  • 0

I have a very simple windows form project with Entity Framework.

Simply I draged my tables from “Data Source” tab in my “form” and it generate for me a “DataGridView” and a “BindingSource”.

Data bound successfully and when I run project I can see “DataGridView” filled with data correctly and I can update any cells value from “DataGridView”.

Problem is I can not insert any rows in my “DataGridView”.

Here is some codes that I wrote hope it be useful to solve problem:

    Teachers_DBEntities context = new Teachers_DBEntities();

    private void SaveItem_Click(object sender, EventArgs e)
    {
        context.SaveChanges();
        MessageBox.Show("saved successfully");
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        teachers_tableBindingSource.DataSource = context.teachers_table.ToList();
    }

Upates for comments

I tested my “BindingSource” and found that it successfully understand if new record insert in “DataGridVeiw”, but changes won’t apply in database when I call context.savechanges();

context.savechanges() works fine when I update a cell, but it doesn’t work when I try to insert a new record in my “DataGridView”.

In my edmx file I mapped all columns correctly and primary key StoreGeneretedPattern property is set to Identity and its Entity Key property is set to true. Its auto-increment property in my SQL Server database file is set to true.

any help is appreciated.

  • 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-09T04:32:30+00:00Added an answer on June 9, 2026 at 4:32 am

    context.savechanges() works fine when I update a cell, but it doesn’t work when I try to insert a new record in my “DataGridView”.

    What do you mean by “it doesn’t work”? New record does not appear in database? Of course it won’t.

    In this line

    teachers_tableBindingSource.DataSource = context.teachers_table.ToList();
    

    you’re breaking DataSource‘s connection to context. Any new item inserted into it will be inserted not into teachers_table, but into List you created over it.

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

Sidebar

Related Questions

I have a VERY simple windows form that the user uses to manage Stores.
I have a very simple table in access. The data is stored from VB.NET
I have a very simple windows Service that is developed in vb.net 2008. When
In my windows forms project I have a parent form that is creates other
I have some very simple HTML: <div id=advisor> <div id=print_this_container> <form> <input type=button value=
I have (what should be) a very simple Windows Forms application. There is a
Ok, so I have a very simple form with next to no logic in
Im playing about with some very simple windows forms. I have an event handler
I have a very simple test app just to play around with Windows Phone
I have a very simple Windows application, with a few controls, a DataGridView and

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.