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?

Community
  • 1
  • 1
colonel_px
  • 305
  • 4
  • 16

1 Answers1

0

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

Kamyar
  • 18,639
  • 9
  • 97
  • 171