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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:33:12+00:00 2026-05-22T17:33:12+00:00

I have a database table with an auto-incrementing ID field. this table is exposed

  • 0

I have a database table with an auto-incrementing ID field. this table is exposed to by code via a Entity Data Model. I am trying to write a new record to this table. I have a method that needs to be responsible for creating these records. This method takes in the property values of the record. It needs to create a record, and write a reference record in another table. Currently, here is what I am trying

public int CreateRecord(string name, string description, List<int> ids)
{
  using (DatabaseContext database = new DatabaseContext())
  {
    Record record = new Record();
    record.Name = name;
    record.Description = description;

    database.Records.InsertOnSubmit(record);
    database.SubmitChanges();

    List<RecordTrack> tracks = new List<RecordTrack>();
    foreach (int id in ids)
    {
      RecordTrack track = new RecordTrack();
      track.RecordID = record.ID;
      track.ID = id;
      tracks.Add(track);
    } 
    database.Tracks.InsertAllOnSubmit(tracks);
    database.SubmitChanges();
  }
}

I can’t seem to get the record to save in this manner. I was able to do it when I passed a Record in that I wanted to insert. But due to other factors, I need a way to purely create the record here from scratch. What am I doing wrong?

Thank you!

  • 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-22T17:33:13+00:00Added an answer on May 22, 2026 at 5:33 pm

    there should be a AddToRecord() function in your database context. Use that function to add your record variable and then call SaveChanges() from your database context.

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

Sidebar

Related Questions

I have a database table like this Port Code | Country |Port_Name -------------------------------------- 1234
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have a database table that looks like this: CREATE TABLE IF NOT EXISTS
Problem: When I use an auto-incrementing primary key in my database, this happens all
I have an sqlite database on android created like this: sqlite> .schema CREATE TABLE
I have a database table with a unique string field and a couple of
Does the primary key have to be the first field in a database table?
I have two database tables: 'MyTable' which has a standard auto-incrementing primary key integer
I have a database table my code inserts a row here everytime user solves
Ok so i have a database table called requests with this structure mysql> desc

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.