2

I'm new to Entity Framework 4.1, and I have pretty much the same problem as this guy: Adding A Custom Property To Entity Framework?

However, when I add a custom read-only property to my Entity using partial classes, I'm unable to access it as a property.

//Auto-generated Entity Class EntityModel.cs
public partial class Model
{
  public string foo {get; set;}
  public string bar {get; set;}
}

//Custom class  EntityModelCustom.cs
public partial class Model
{
   public string baz
   {
      get
      {
       return string.Format("{0}+{1}", this.foo, this.bar);
      }
   }
}

In my code, when I try to obtain property

Model m = new Model();

m.foo and m.bar are accessible. But I can't access m.baz which is what I want :-(

What am I doing wrong?

1 Answer 1

0

Make sure both of your definitions are in the same namespace. usually, this is the cause of not seeing the other property.

Sign up to request clarification or add additional context in comments.

2 Comments

They're both in the same namespace.
They must also be in the same assembly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.