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.