Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Working with Entity Framework and ServiceStack


While ServiceStack is bundled with OrmLite, you could make it work with any number of ORM tools. In many situations, developers might need to make use of domain models already built against other systems, for instance Microsoft's Entity Framework. We'll cover a little bit about how to use Entity Framework with ServiceStack in this recipe.

Note

It's important to remember that the code in this recipe is not production tested. It should work fine, but your mileage might vary.

Getting ready

In this example, we'll build a custom domain model with Entity Framework and then use it with ServiceStack. We'll use the code-first paradigm to build up an EfContext model that extends DbContext, and which we'll use when we need to access data in our services.

Before you can use Entity Framework with your solution, you might need to install the NuGet package, as shown in the following section.

How to do it…

  1. Install EntityFramework from NuGet, as follows:

    Install-Package...