> ## Content Index
> Fetch the complete content index at: https://www.mrstebo.co.uk/llms.txt
> Use this file to discover other available public pages before exploring further.

# Entity Framework Model Mapping
- URL: https://www.mrstebo.co.uk/entity-framework-model-mapping/
- Published: 2015-04-09T23:00:00.000Z
- Updated: 2023-05-15T23:43:26.000Z
- Description: The EntityTypeConfiguration class
- Author: Steven Atkinson
- Tags: Software Development, Software Engineering, Entity Framework, Database, Dotnet

Entity Framework 6 is pretty awesome, and there is probably a part of it that you are not fully aware of.

Let me introduce you to the [EntityTypeConfiguration](https://msdn.microsoft.com/en-us/library/gg696117%28v=vs.113%29.aspx?ref=mrstebo.co.uk) class.

With this class you can separate your model mappings from your [DbContext](https://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext%28v=vs.113%29.aspx?ref=mrstebo.co.uk).

Here is an example of the folder structure that works with this strategy.

![](https://miro.medium.com/v2/resize:fit:242/0*m56-Ulbk4yrokq_C.png)

# Here is a simple step by step example of how to implement Entity Framework Model Mapping

Create your model

Set up your DbContext

Setup your mapping using the EntityTypeConfiguration class.

# Now we are ready to go!

Here is a UserService class that will use our configured context.

# Piece of cake, right?

You can use this style for any type of model. You can also add associations to models, but I shall save that for another day!