1 Replies - 3505 Views - Last Post: 07 September 2011 - 04:11 AM Rate Topic: -----

#1 IndieDev   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-September 11

Architecting a solution that will use WCF and Entity Framework 4.1

Posted 07 September 2011 - 01:58 AM

I'm working on a new application that is going to be built from scratch, and a requirement is to use Entity Framework 4.1 for the Data Access Layer.

I've not used Entity Framework before in anything other than simple web apps that just need to be built quickly and have the basic ability to display data from the database, then store new data through a simple Web Form.

With anything more complicated i've often used Microsoft Enterprise Library Data Block, and wrote all the stored procedures for storing and accessing data.

What i'm essential looking at developing is a Database for storing work items / tasks, but it will need to have (eventually) a Web interface, aswell as the original WPF UI we are developing.

My reasoning for using a WCF service is so that the User Interfaces can be built and rely on that for pulling down data.

The application will be multi-layered, but the Web Service and Database (and future Web Interface) will all be on the same physical tier for the foreseeable future.

So far I have this in my mind:

WPF Application -> WCF Service -> Entity Framework (DAL) -> Database

The main issue i'm having is, once I use the generated EF entities to get data from the database, what is the best way/order to:

  • Apply Business Logic
  • Create a DTO to send down to the client

Would this be the correct, sensible thing to do, or have I made it too complicated:

  • Send request from the WPF client to the web service
  • Get data from the Database into an auto generated EF entity (In the Web Service Code)
  • Create a DTO from this data
  • Send response back to the WPF client
  • Once the DTO gets back to the client, create the relevant objects from the DTO
  • These objects will then have methods that can be run to modify the data etc
  • Re-package into a DTO and send back to the WCF service telling it to update the data
  • WCF service creates Entities from the DTO and then updates the database

This seems a bit long winded. I'm sure I want to create DTO's, as sending an EF entity accross a WCF service and working with it directly wouldn't really be a good idea imo.

But there seems to be a lot of objects being created, and I think i'm making it more complicated than it needs to be.

Essentially the front ends are all just updating / adding data to the database, with the data going Via the WCF service.

I hope I have tried to explain what I want to achieve, and what my current plan is. Looking for advice on how wrong this may be, or where I may be right about any of it.

Any advice greatly appreciated.

All the best.

Is This A Good Question/Topic? 0
  • +

Replies To: Architecting a solution that will use WCF and Entity Framework 4.1

#2 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1533
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Architecting a solution that will use WCF and Entity Framework 4.1

Posted 07 September 2011 - 04:11 AM

First, I would suggest looking into WCF RIA Services. This will help you out with getting the Entity Framework created classes down to the client.

However, by default, WCF RIA Services is only for Silverlight. Though it does seem that some people have been able to get it to work with WPF.


I haven't tested it though. If you can get it to work, this would be the best way to go.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1