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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:58:58+00:00 2026-05-24T08:58:58+00:00

I am using entity framework 4.1 code first. I have a GrantApplication class: public

  • 0

I am using entity framework 4.1 code first.

I have a GrantApplication class:

public class GrantApplication
{
   // Just some of the properties are listed
   public int Id { get; set; }
   public GrantApplicationState GrantApplicationState { get; set; }
}

GrantApplicationState is an enum and looks like this:

public enum GrantApplicationState
{
   Applying = 1,
   Submitted = 2,
   cknowledged = 3
}

Just before I go and add the grant application the database I set the grant application state:

public void Insert(GrantApplication grantApplication)
{
   // Set the current state to applying
   grantApplication.GrantApplicationState = GrantApplicationState.Applying;

   // Insert the new grant application
   grantApplicationRepository.Insert(grantApplication);
}

In my database I have a GrantApplication table with a GrantApplicationStateId that links to a GrantApplicationState table.

How do I get EF to add the state id from GrantApplication.GrantApplicationState to the GrantApplicationStateId column? Is this possible? And when I retrieve the GrantApplication object then it will need to be set as well. Is this the way to do it or do I have to create another property in my GrantApplication class called GrantApplicationStateId?

  • 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-24T08:58:59+00:00Added an answer on May 24, 2026 at 8:58 am

    You must create another property:

    public class GrantApplication
    {
    
       public int Id { get; set; }
       ...
    
       public int GrantApplicationStateId { get; set; }
    
       [NotMapped] // Perhaps not need
       public GrantApplicationState GrantApplicationState 
       { 
           get { return (GrantApplicationState)GrantApplicationStateId; }
           set { GrantApplicationStateId = (int)value; }
       }
    }
    

    EFv4.1 doesn’t support enums at all – you cannot map them. This will change in EFv4.2.

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

Sidebar

Related Questions

I have been using Entity Framework CTP with Code-First as in this tutorial by
Using the Entity Framework 4. I have created a Code First database in the
I am using MVC3 with Entity Framework Code First. I have the following model.
I'm using Entity Framework 4.1 Code First. In my entity, I have three date/time
First some brief background: I have an existing ASP.NET MVC 1 application using Entity
Is there a way in Entity Framework 4 (using CTP4 and Code First if
How to declare a one to one relationship using Entity Framework 4 Code First
I'm using Entity Framework 4 Code First in my .net MVC 2.0 project and
When using the CTP 5 of Entity Framework code-first library (as announced here )
I'm having trouble mapping two entities together with Entity Framework CTP5 using Code First

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.