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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:43:20+00:00 2026-05-29T10:43:20+00:00

Here is my Master Entity who will contains a list of Language public partial

  • 0

Here is my Master Entity who will contains a list of Language

public partial class WebSite
    {
        public WebSite()
        {
            this.WebSiteLanguages = new HashSet<WebSiteLanguage>();
        }

        public int Id { get; set; }
        public Nullable<int> WLUserID { get; set; }
        public string DomainName { get; set; }
        public Nullable<bool> IsActive { get; set; }
        //[Required]       
        public virtual ICollection<WebSiteLanguage> WebSiteLanguages { get; set; }
    }

My WebSiteLanguage Child class is

public partial class WebSiteLanguage
    {
        public int Id { get; set; }
        public string LanguageName { get; set; }
        public Nullable<int> WebSiteID { get; set; }
        public bool IsDefault { get; set; }

        public virtual WebSite WebSite { get; set; }
    }

In my View, I can Add many language as I want within an ajax call.

enter image description here

My Question is :
Is it possible to make the

public virtual ICollection WebSiteLanguages { get;
set; }

Required. The Website Entity is not valid if there is no WebSiteLanguage created.

Thanks a lot.

  • 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-29T10:43:21+00:00Added an answer on May 29, 2026 at 10:43 am

    As per post http://blogs.msdn.com/b/adonet/archive/2011/05/27/ef-4-1-validation.aspx navigation properties are excluded from facet validation “as you could set the associated FK value and the navigation property would be set on SaveChanges()”. To validate that a navigation property is not null you can:

    • create a custom attribute that validates it (be it on the type or on the property)
    • implement IValidatableObject interface that does the above
    • override DbContext.ValidateEntity protected method so that it validates that the property is not null and if this is the case calls base.ValidateEntity() to validate other properties (see this for more details: http://blogs.msdn.com/b/adonet/archive/2010/12/15/ef-feature-ctp5-validation.aspx)

    The 3rd solution seems to be the cleanest.

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

Sidebar

Related Questions

Here is my master page code behind: namespace mysite.MasterPages { public partial class Main
I modified this simple countdown timer form here: https://github.com/lunaryorn/snippets/blob/master/qt4/countdown.py as follows. Now I want
I'm trying to do something like this https://github.com/brikou/AcmePizzaBundle/blob/master/Entity/Factory/ ... in symfony2 beta1, but it
In need of a regex master here! <img src=\img.gif style=float:left; border:0 /> <img src=\img.gif
Here are the tabs in the master page: <nav> <ul id=menu> <li><%: Html.ActionLink(Home, Index,
Here's what I'm doing. My master branch has a bug in it and I
I have a master record which I'd like to use with. Here's a very
Going through the microsoft authentication tutorial listed here they have you create a master
Visual Studio freezes up continually when I'm editing master pages or aspx files. Here's
I'm having troubles using the facebook binding from here ( https://github.com/mono/monotouch-bindings/tree/master/facebook ) and the

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.