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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:30:00+00:00 2026-06-17T10:30:00+00:00

When using code-first EntityFramework, I need one property to be set before the others

  • 0

When using code-first EntityFramework, I need one property to be set before the others – how do I specify the order that it calls the property sets, when it is creating the objects from the database?

E.g.

public class Person
{
    public string Name { get; set; }
    public string Something 
    { 
        get { return something; } 
        set
        {
             something = value + " for " + Name;
        }
    }

    private string something;
}

In the code above, I need the Name property to already have been set by the time it sets the Something property.

This isn’t the actual example – I know there are other ways to achieve that literally, but I’m not after those, just how I can tell EF to set Name before Something.

  • 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-17T10:30:01+00:00Added an answer on June 17, 2026 at 10:30 am

    I am trying to understand the context of your question. I am going to make the assumptions that:

    1. The value passed to the setter is not another calculated property
    2. the value passed to the setter is intended to be stored in the database
    3. If name is updated you would want Something to be updated to reflect the new name?

    I think your mistake here is trying to add a derived portion to the value you are looking to store. Calculate the pretty name in another property, or on a get:

    UPDATE had an example overriding the get on the Something Property, but removed as I feel it is bad practice.

    public class Person
    {
    public string Name { get; set; }
    
    public string Something { get; set; }
    
    public string getFancySomething { 
        { return Something + " for " + Name; } 
    }
    }
    

    Finally – (and here is where I could use some help as I have not run into a situation where I needed to do something like this) my guess is that you do not need to be storing the partially calculated property Something in the way you were attempting, but if you do need to, I think additional detail might help someone provide you with a better answer.

    UPDATE 2
    As described in my comments – not sure this would work, and it feels very wrong, but you could try something like:

    modelBuilder.Entity<Person>().Ignore(x => x.Something);
    

    and then in the setter:

    public class Person
    {
    public string Name { 
       get { return Name; }
       set { 
           Name = value;
    
           Something = lookup();
        }
    }
    }
    

    Again this will depend on you needs, and would not satisfy any need to pass this value in, and I am not sure this is a great idea.

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

Sidebar

Related Questions

I need to map a many-to-many relationship using Entity Framework Code First. Its a
I'm using Entity Framework 4.3.1 Code-First and I need to split an entity between
I'm using EntityFramework code first with migrations. From the package manager console, I'm running
I'd like to map a one-to-one relationship using Entity Framework 5 Code First like
I have a problem in Entity-Framework, using Code-First, that I couldn't solve. Having entities
I'm using Entity Framework 4.1 Code First and I have a table that has
We are using Entity Framework Code First with Foreign Key relationships. We investigating on
When using Entity Framework Code First 4.3.1 it is possible to create relationships with
I'm using Entity Framework Code First v 4.3.0 I have a two entities with
Hello everyone my problem is very simple. Using entity framework code first I want

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.