views:

107

answers:

1

Hi, 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?

A: 

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.

Roger Alsing