Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Data Services or Entity Framework

I have to develop an application to store some flat files in the DB.. The Console application and the SQL Server will be on the same machine, which of these two options is the best?

  • Create WCF Data Services and use it from the console app
  • Use directly the Entity Framework entities from the console app

Generally, when it is better to use WCF Data Services or Entity Framework?

THANKS!

like image 470
andrew0007 Avatar asked Jan 23 '11 10:01

andrew0007


People also ask

Can we use Entity Framework in WCF service?

In this post, we will go through how to use WCF to create a REST service, also using the Entity Framework to connect to a database. We have a SQL database that holds customer information.

What are WCF services?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

What is WCF data tools?

It's a downloadable package which extends the Add Service Reference functionality in Visual Studio 2012 to support OData feeds. Without it OData feeds can't be added as services references to a Windows Store app project.

What is the purpose of Entity Framework used with WPF?

Entity Framework is an open-source ORM framework for . NET applications supported by Microsoft. It enables developers to work with data using objects of domain specific classes without focusing on the underlying database tables and columns where this data is stored.


1 Answers

Those are two totally different technologies:

  • Entity Framework is an OR mapper to make your database access easier; you can compare this to e.g. NHibernate, Linq-to-SQL, Subsonic, Genome, or other OR mappers

  • WCF Data Services is a way to expose your data models to the outside world over HTTP/REST; compare this to legacy ASMX webservices, pure WCF services, other service technologies

You cannot compare the two - they're totally different beasts, and in many solutions, they will be working together - one cannot replace the other.

If you have a console app that needs to read data from a database, you can either use Entity Framework directly - in that case, your console app must have a direct connection to the database, and it's tied to the Entity Framework technology.

The option of exposing the data using a WCF Data Service adds another layer - your console app doesn't access the data directly, but it just calls a WCF Data Service. Now you basically have two parts: your console app as the client, and some kind of a service app that will provide the data. In that case, your client doesn't need to know anything about Entity Framework or anything like that - you could also easily add a second client, e.g. a web app. But the service app that provides the data will still need to be able to directly connect to the database using Entity Framework.

So in the end, you're not really replacing Entity Framework with WCF Data Services - you're just adding another layer of indirection, but in the end, to get at the data, you still need some kind of data access technology (like Entity Framework).

like image 137
marc_s Avatar answered Oct 28 '22 13:10

marc_s