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

# Hello, Entity Framework
- URL: https://www.mrstebo.co.uk/hello-entity-framework/
- Published: 2015-04-08T23:00:00.000Z
- Updated: 2023-05-15T23:43:16.000Z
- Author: Steven Atkinson
- Tags: Software Development, Software Engineering, Entity Framework, Database, Dotnet

With the near release of [Entity Framework 7](https://github.com/aspnet/EntityFramework?ref=mrstebo.co.uk), I thought it was about time I gave my two cents on the usefulness of the current version. I’ve been using it for a few years now, and have found it easy (and fun) to use.

# But, what is Entity Framework?

Entity Framework is an open source object-relational mapping (or [ORM](http://en.wikipedia.org/wiki/Object-relational%5Fmapping?ref=mrstebo.co.uk) for short) framework for ADO.NET. This means you can create models in your code that map to tables in your database. It can plug in to an existing database and can automatically generate models for you (although this is not possible when using Code First).

It’s nice level of abstraction means you can hook up all sorts of databases to it. For example, you could have a connection defining a connection to a [LocalDB ](http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx?ref=mrstebo.co.uk)instance, and another for connection to an MySQL database.

# Why should I use Entity Framework?

Sure, you could use the standard DbConnection classes meaning you have to:

- **Manually* create connections to a database.
- **Manually* create SQL commands to perform queries or actions on your database.

Here is an example UserService to demonstrate the above.

****But what if you want to change what type of database you are using?***

- You would have to **manually* modify all your connection strings.
- You would have to **manually* modify all your queries to make sure they work with the new connection.

# Entity Framework to the rescue!

With Entity Framework you only need to:

- Add the new database dependencies (easily done via [NuGet](https://www.nuget.org/?ref=mrstebo.co.uk))
- Modify the connection string in your app/web.config

Here is how the UserService will look using Entity Framework.

**So which one would you prefer to use?*

# Are there any alternatives?

Here are a few alternatives that you can check out.