I create a desktop application using C# + EF 4.0. I’m aware that it’s normal to add a custom method to Entity Framework EntityObject using partial classes:
public partial class EntityModel: EntityObject{
public void MyMethod() { ... }
}
But I need to add a custom field to store an information that I don’t want to hold in database.
So would it be normal or is there any way to do it?
Sure, just add the property you need like:
But bear in mind that it’s stateful for that object so it’s not going to persist anywhere unless you do that yourself and it’s going to hold a different value for each object, unless of course you made it static, but I would strongly recommend against that.