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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:35:52+00:00 2026-05-13T10:35:52+00:00

I have 2 tables, Table1 has a primary key ‘CustomizationId’, and Table2 has a

  • 0

I have 2 tables, Table1 has a primary key ‘CustomizationId’, and Table2 has a FK Customizationid which matches this. Table2 has no primary key.

I am trying to add a new record from a web based form. I attempt to save this to the database and I get an error:

            Customization customization = new Customization();
            Code code = new Code();
            customization.Name = CustomizationName.Text;               
            customization.LastUpdated = DateTime.Now;

            code.Top = top_js.InnerText;
            code.Bottom = bottom_js.InnerText;

            //code.CustomizationId = customization.CustomizationId;

            customization.Code = code;              
            entities.AddToCustomizations(customization);
            entities.SaveChanges();

When I call SaveChanges I am getting an error, whether or not I add in the commented line.

Unable to update the EntitySet 'Code' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

How do I handle this situation? I just want to add in the code at the same time that I add in the Customization. The ‘Code’ table should have the Customizationid set to the PK/Identity set by Customization.

Any ideas?

  • 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-13T10:35:52+00:00Added an answer on May 13, 2026 at 10:35 am

    As far as the EF is concerned the table without a PK is a View.

    This means you have two options:

    1. Tell a little white lie, and convince the EF that the ‘view’ is a table
    2. Add modification functions (Insert/Update/Delete) so you can edit them.

    Generally modification functions are stored procedures, but you can actually add T-SQL directly to the SSDL if you don’t have access to the database…

    I.e. something like this in the <StorageModel> element of the EDMX for each action (insert, update and delete):

    <Function Name="InsertCode" BuiltIn="false" IsComposable="false" >
           <CommandText>
                    INSERT dbo.TCode(ID, Name) VALUES (@ID, @Name)
           </CommandText>
           <Parameter Name="ID" Type="int" Mode="In" />
           <Parameter Name="ID" Type="nvarchar(max)" Mode="In" />
    </Function>
    

    Once you have the modification functions in your SSDL you need to map them so that the EF uses them as required.

    In your situation I recommend (1).

    Hope this helps.

    Cheers
    Alex

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

Sidebar

Related Questions

I have this table in an Oracle DB which has a primary key defined
I have 2 tables. Table1 has fields A, B, C, D and Table2 has
I have 2 tables, product has a primary key and a name, price has
I have a table that has a primary key that's an INT... I have
I have 2 tables: 1. Employees 2. Vouchers Employees table has a single primary
I have two tables one has a three column composite key. The other needs
I have two tables: foo (primary key: foo_id) and foo_entry (primary key: foo_entry_id; foreign
I have two tables user and location user has id(primary) and location fields/columns location
I have 3 tables (archive has many sections, section (may) belong to many archives):
I have a poorly designed database. One of the most important tables has 11,000+

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.