Differences between ASP.NET MVC framework and Entity Framework - asp.net-mvc

I'm going to be starting a new project with ASP.NET and I would like to use some framework which speed up the process. Recently I have heard that there are two main frameworks in that platform: the MVC and the Entity framework. Are they compatibles? If not, what are your advices on what to use and why? What are they best properties?

You can't compare them. These are 2 different things.
Entity framework is ORM mapper, Asp.Net Mvc is a framework that helps building web applications.
Actually - they even aren't mutually exclusive and you can use them both together quite nicely.

MVC is an architectural pattern to build applications; entity framework is a object relational mapping framework. Quite different animals.
And yes, they can be used together, no problem.

ADO.NET Entity Framework is an object-relational mapping (ORM) framework for the .NET Framework.
http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework
http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx
Other entitty frameworks are -> LINQtoSQL, NHibernate etc.
Model–View–Controller (MVC) is an architectural pattern used in software engineering.
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
http://en.wikipedia.org/wiki/ASP.NET_MVC_Framework

They're different things entirely.

Although they're different things entirely they are compatible. I am using both frameworks on a project now.

You can use both of them into a single project.
Entity framework is object-relational mapping (ORM) framework. It is an
enhancement to ADO.NET that gives developers an automated mechanism
for accessing & storing the data in the database.
Model-View-Controller (MVC) is an architectural pattern that separates
an application into three main logical components: the model, the
view, and the controller.

These are 2 different things as mentioned before.
Entity Framework is an ORM -> a Mapper to help you get data.
asp.net is a framework to STRUCTURE your project ,with Objects and Classes, not related to entity.

Related

Using Entity Framework in MVC 5

I am creating a web portal on real estate. I am building it on ASP.NET MVC 5. For database connectivity, should I use Entity framework or not? and why? If not then what should I use? (I was using normal sqlclient method when I was working on web forms).
Updating for more clarity :
I am having very complex query scenarios in my project such as I have to search n various filters etc. I am also using angular ajax for many features. Now can anyone suggest either go with EF or not?? Thanks
Use an ORM (like Entity Framework) because it will read data from a database and give you back some easy to use classes, manage change tracking, allow easy updates, etc, etc. These two articles may help as they list of ORMs and contain some performance data:
Fetch performance of various .NET ORM / Data-access frameworks
Fetch performance of various .NET ORM / Data-access frameworks, part 2
Also you may want to take a look at this Stackoverflow question:
Are there good reasons not to use an ORM?
There are several infrastructures designed to help you create websites using ASP.NET. The EntityFramework, which is part of ADO.NET, help you do ORM, MVC 5 is, well, for MVC. There are others, like Razor.
All in all, it seems fine to use EF for DB connectivity and ORM, as it seems to be the standard.

Can you use Orchard CMS with Entity Framework 5 instead of NHibernate?

Can you use Orchard CMS with Entity Framework 5 instead of NHibernate?
I'm writing an MVC 4 Code First app and don't want to have to learn NHibernate - I would like all my projects to be consistent and use Entity Framework 5+
Thanks.
No. That is not possible, sorry.
you don't have to know how nhibernate works, using the Orchard content manager and standard Linq is enough in almost all scenario's. We use entity framework in our other projects. And the migrations in Orchard are simple but powerfull. Think about it.

using the ASP.NET MVC2 without the Entity Framework

I am learning asp.net MVC, as I have been using the sqlconnection, sqlcommands etc from my initial phases, I would like to initially start learning asp.net MVC without using the entity framework.
Can you give me a link or any idea of using the models to process data without using the entity framework.
So without entity framework you'll be using ADO.NET (See MSDN)
Those classes you mentioned SqlConnection, SqlCommand are part of the ADO.NET framework. The two Microsoft frameworks that build on this are Entity Framework and LinqToSQL.
If you don't want to us either you have to write you own models/classes, and then methods to persist those models into your database. (This is essentially what EF does) You won't get any LINQ or designers etc.
Also, ADO.NET does have a way to create strongly typed datasets. This might help a little.
What you are doing might help you understand whats going on under the covers, but do realize frameworks like Entity-Framework save a lot of time and effort by generating models for you.

2 issues about ASP.NET MVC,LINQ to SQL

Describe the Advantage and Disadvantage of ASP.NET MVC in comparison with ASP.NET Web form.
Depend on your choice to implement a new design or develop and compare source code or just explain the concept idea, the tasks of LINQ to SQL class that using as ORM, make comparison with NHibernate on the concept of developing the Data Access Layer for the application.
MVC is a popular standard. I recommend using ASP.MVC than Webforms because it has all the advantages of MVC Architecture. and you can use many view engines such as Razor and NDjango.
For ORM you should use Entity Framework. It's really a wonderful framework.
The advantages of New Products such as ASP.NET MVC and Entity Framework is that THE OLD PRODUCTS SUCKS and the disadvantage is the you need to LEARN AGAIN.

Example of how to use active record with asp.net mvc

I am looking for the best approach to using NHibernate and MVC.net.
I have gone through http://www.codeproject.com/KB/architecture/NHibernateArchitecture.aspx
Someone has pointed to the use of Castle project Active record.
My aim is to eliminate the need for any nhibernate dependencies within my domain.
I want a quick and easy domain model that is persistable with NHibernate.
Can I have a simple example and and some explanations please from which I can learn to use the castle project to build a simple application in MVC.net.
Thanks
There is no "best" approach to using NHibernate and asp.net mvc. NHibernate is a very flexible tool, you can use it in quite different ways depending on your project's needs.
Castle ActiveRecord will not remove any dependencies on NHibernate in your domain. In fact, it will introduce more dependencies, as you'll need to mark your classes with some attributes.
About sample projects using Castle ActiveRecord, see this question.

Resources