4

I'm fairly new to mvc, asp.net, and .net framework in general.

I understand what models are, controllers and views, but what I don't get it is Entity Framework. I developed websites before using php, and when I needed to store some data I simply do that using MySql databases. I thought this is the case with asp.net, same concept but instead of MySql, Microsoft Sql server is used. Now I started to learn .net framework and I watched a lot of online tutorials and saw them using some classes inherited from DbContext to store data! Can anyone tell me where these classes store the data and why don't we use Microsoft Sql server instead?

4
  • 2
    Entity Framework is an ORM, it is not a Data Store. SQL can still be used, but a lightweight replacement like SQL Compact or SQL Express is used automatically by default (depending on your computer configuration) when you don't specify a full instance. For that matter, you could use MySQL, assuming you set up the proper connectors. Commented Jul 12, 2015 at 14:36
  • @Claies what about the DbContext classes? Commented Jul 12, 2015 at 14:37
  • DbContext is a class from Entity Framework, which performs the work of looking at your model and determining what SQL calls should be made to perform your data interaction so that you don't have to write raw TSQL. Commented Jul 12, 2015 at 14:39
  • 1
    essentially, you are trying to compare apples to apple juice here. Commented Jul 12, 2015 at 14:39

1 Answer 1

11

Entity Framework is an Object Relational Mapping tool (ORM), a layer that sits between your database and code. The idea is that the ORM is database agnostic and will handle writing the SQL for you, so that you could (in theory) swap between SQL Server, MySQL, or whatever database you want with only configuration changes.

You can skip Entity Framework and use SQL directly with ASP.Net. Your tutorials just happen to use Entity Framework.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.