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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:12:06+00:00 2026-06-13T15:12:06+00:00

after several attempts and some searching I finally decided to try it here. Short

  • 0

after several attempts and some searching I finally decided to try it here.

Short story: I have created quite a ‘normalized’ database design for content management system application and now I am trying to map it to EF entities.

enter image description here

I have M:N relationship between Pages and their content (ContentVersion table) – connected by table Content. This is because the application is multilingual and I am going to store recent history of content edits.

Now, I could just create DbContext from my db, scaffold few controllers and have a solid base, but there would be a problem with that. When I would try to create new Page, I would be allowed to basically enter just a Title and Slug, but there would be no content for that page. I can of course connect that somehow with other entities and make some hierarchical business logic that would be updating several entities every time, but I first wanted to try a bit more abstract approach.

I think I basically need entity splitting over 3 related tables. I want to create an entity (let’s call it FinalPage), that could be used to work with page as one piece -> use it to scaffold controllers etc.

FinalPage is something that user fills up when creating a new Page, so it would contain:

Title (from Page entity)
Slug (from Page entity)
TemplateId (from Page entity)
LanguageId (from Content entity)
Title (from ContentVersion entity)
Body (from ContentVersion entity)
+ other related fields from ContentVersion entity

When I would generate ‘create new’ page for it, I would fill everything and everything would get saved into appropriate tables.

I tried creating new entity in my entity model, mapping properties to different tables.. tried several approaches, but never got working solution. Mostly because of typical ‘you need to map every key’ error. I was checking this post from Rob Bagby, but he was connecting just two tables, that shared same key.

I also tried something what felt really silly… creating entity (entA) from Page and Content entities – connected by PageId property. And creating second one (entB) from Content and ContentVersion – connected by ContentId. Then I wanted to create third (entC) that would connect entA and entB. That also didn’t work (and I am actually glad, because that would be really weird solution).

I feel like I am:
a.) Missing something obvious.
b.) Having a bad database design.
c.) Wanting too much from EF.

Any help is welcomed.
– If you see something terrible in the database design, please let me
know.
– If you know, how to achieve my goal, please share.
– If you have experience with this type of apps and have better solution,
I would like to hear about it.

I am also basically looking for some best-practices.

  • 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-13T15:12:07+00:00Added an answer on June 13, 2026 at 3:12 pm

    Sounds like you’re trying to make your ORM fit your UI model, which is not the way to do it. You should create a new class that represents the data you want to capture from a form, and then process that into the various table as required. So your model that would be used when creating a new page would be something like this:

    public class FinalPage{
        public string Title { get; set; }
        public string Slug { get; set; }
        public string Body { get; set; }
        public int TemplateId { get; set; }
        public int LanguageId { get; set; }
    }
    

    When the user submits the form (you’ve not mentioned what UI you’re using) you would process those values into the various ORM objects.

    public void SaveData(FinalPage model){
        var page = new Page{
            Title = model.Title,
            ...
        };
        db.Pages.Add(page);
    
        var contentVersion = new ContentVersion{
            Body = model.Body,
            ...
        };
        db.ContentVersions.Add(contentVersion);
    
        ...
    }
    

    This is the difference between a View Model and a Database Model, the do not have to be the same, and the business logic is applied between the two entities. An alternative to this, which I have used in a previous project is to have a class that contains the ORM objects that you want to use, this way you get the DataAnnotation validation stuff in your UI.

    public class FinalPage{
        public Page Page { get; set; }
        public ContentVersion ContentVersion { get; set; }
        public Content Content { get; set; }
    }
    

    Then display the appropriate fields from each of the inner objects. In MVC4 with Razor:

    @Html.EditorFor(m=>m.Page.Title)
    

    This will produce the validation errors that you expect, and that are defined in the data model, however you need to be aware that you may need to ensure that the objects are handled correctly later (for instance in MVC your ModelState will nearly always be Invalid). Personally I would recommend the first approach as this is the traditional method for operating with differing UI and ORM models. The general rule I go with is, use the ORM model if you can, but as soon as it becomes a little tricky, switch to a ViewModel class to represent your values.

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

Sidebar

Related Questions

After several failed attempts using ExtJS I have now decided to use javascript.The requirement
so i have made several attempts at this, but decided i needed some advice
After several unsuccessful attempts to use JXTA api, i have decided to roll out
After looking at several questions/answers here, I'm not seeing what I think I need.
I had a class that only worked in Delphi 7 and after several attempts
I have, after some help ( MSChart - Forcing a line chart to draw
I'm trying to implement the Sieve of Eratosthene in C++. However after several attempts
After several attempts to change the background of a button, and getting errors of
After several attempts to find a unique solution for my thought, I've had no
After several attempts I couldn't figure out a efficient way to do this. I

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.