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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:28:56+00:00 2026-05-17T01:28:56+00:00

We have a simple Table per Type Entity Framework 4.0 model :- ALl classes

  • 0

We have a simple Table per Type Entity Framework 4.0 model :-

alt text

  • ALl classes are all POCO’s.
  • Post class is abstract.
  • Discussion and List are classes are concretes, that inherit’s from Posts (as shown in the diagram).

When we try to save a Discussion, we do the following code :-

Posts.AddObject(discussion);

And the Sql Server syntax is in two parts. The second one errors. Notice the sql schema namespace? why is that?
(Code taken from EFProf)

insert [dbo].[Posts]
      ([Subject],
       [UniqueSubject],
       [Content],
       [CreatedOn],
       [ModifiedOn],
       [IsVisible],
       [UserId])
values('Test Subject' /* @0 */,
       'sdfsdfsdfsdfsfdssd' /* @1 */,
       'this is a lot of content - pew pew pew' /* @2 */,
       '23/09/2010 12:22:08 PM +10:00' /* @3 */,
       '23/09/2010 12:22:08 PM +10:00' /* @4 */,
       1 /* @5 */,
       1 /* @6 */)
select [PostId]
from   [dbo].[Posts]
where  @@ROWCOUNT > 0
       and [PostId] = scope_identity()


insert [XWingModelStoreContainer].[Discussions]
      ([PostId])
values(20132 /* @0 */)

Notice the table name is [XWingModelStoreContainer].[Discussions] ?? Shouldn’t that be [dbo].[Discussions] ?? How can we fix this, please?

.

.

UPDATE:

Also, here’s another screen shot of the properties of our designer .. so u can see that we thought that it should be calling [dbo] as that is the default Database Scheme Name ..

alt text

and in the Xml edmx file.. there’s two name’d lines..

<edmx:StorageModels>
<Schema Namespace="XWingModel.Store" Alias="Self" 
     Provider="System.Data.SqlClient" ProviderManifestToken="2008"
      xmlns:store="http://schemas.microsoft.com.. snip ..."
      xmlns="http://schemas.microsoft.com/ ..snip ..">
    <EntityContainer Name="XWingModelStoreContainer">
.....

and ..

<!-- C-S mapping content -->
<edmx:Mappings>
  <Mapping xmlns="http://schemas.microsoft.c.. snip .." Space="C-S">
    <Alias Key="Model" Value="XWingModel" />
    <Alias Key="Target" Value="XWingModel.Store" />
    <EntityContainerMapping CdmEntityContainer="XWingEntities" 
        StorageEntityContainer="XWingModelStoreContainer">
.......

Does this also help? I have no idea how those names got there (i’m assuming autogenerated) and how do i need to change them? If so, it looks like it’s only possible via the xml file .. which is fine .. but feels … wrong?

Cheers 🙂

  • 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-17T01:28:57+00:00Added an answer on May 17, 2026 at 1:28 am

    I was having a similar issue, and the problem was solved by making sure the child tables have the Primary Key set.

    Even though the child tables have an FK to the parent table, you still need to set these fields as the PK, otherwise EF does not know how to execute the INSERT on the child tables.

    So in your example, try setting PostId as the primary key on the Discussion table, then refresh your model.

    Give that a go.

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

Sidebar

Related Questions

I'm trying to do a Table Per Hierarchy model in Entity Framework(VS 2008 sp1,
I have a simple table view which is editable. All I need the user
I've employed hibernate's table-per-class-hierarchy as outlined here . I've got a simple 1-tier hierarchy
My situation I have an entity model with a base class ItemBase which defines
I have simple table in Sybase -- Creating table 'SimpleText' CREATE TABLE [dbo].[SimpleText] (
I have simple table creating script in Postgres 9.1. I need it to create
I have a simple table that has this structure: <table> <thead> <tr> <td>Some info</td>
I have a simple table maintaining messages between users. The table structure looks like
I have a simple table like this <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
I have a simple table. The first column has max-width set at 15px. It

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.