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