How can I extend Entity Framework generated entity but not map to DB column

My position: 1. I have an entity model created by EF with a modeler. 2. The database is generated by EF through the model designer. 2. All properties of objects are mapped to the database columns, respectively. Ex. my generated "problem" object:

[EdmEntityTypeAttribute(NamespaceName="MyModel", Name="File")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class File : ContentItem
{
    //some properties

    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Int32 Major
    {
        // get and set are here
    }

    //another properties
}

      

I need to: 1. Extend the object manually with a single scalar property (create a partial class in the same namespace that was generated); What I've done:

public partial class File
{
    [DataMemberAttribute()]
    public double ContextWeight { get; set; }
}

      

  1. This new ContextWeight property will be evaluated and initialized when the service performs certain functions. Then I need this property available on the client (proxy).

Problem: When I create a service project and then update the service reference in the Client (proxy) project, then on the client (proxy) I don't see this new property existing in the File class.

Note. I don't need a ContextWeight property map for any DB column.

Could you please advise what I should add (maybe some attributes are missing or something else)?

+3


source to share





All Articles