3

i want extend an entity framework model with a temporany attribute. I need it only in a mvc form. I don't need save it in the db.

How can i do it?

1 Answer 1

5

Create a partial class for the entity you want to extend

e.g.

//must be in the same namespace as the Customer entity in the model
public partial class Customer
{
     public string MyProperty{get;set;}
}

This property will be unmapped and you can fill it with data after you run a query or on materialization.

OR

Create a wrapper class for your entity which expose both the unmapped property and the mapped properties the properties you need in the view.

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

Comments

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.