O'Reilly logo

Fluent Entity Framework by Rebecca M. Riordan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required