Extending the model

Image

Whether you use the ObjectContext or DbContext API, the classes and most of the methods that the Entity Model Designer creates for you are declared as partial members, so you can easily extend them.

In recipe.cs

public partial class Recipe{ ... partial void OnRecipeNameChanged(); ...}

In your code file

public partial class Recipe{ Int32 NewProperty (get; set;} ... partial void OnRecipeNameChanged() {   // do something } ...}

In recipe.vb

Partial Pubic Class Recipe ... Partial Sub OnRecipeNameChanged(); ...End Class

Partial Public Class Recipe Property NewProperty as Int32 ... Function OnRecipeNameChanged()   'do ...

Get Fluent Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.