views:

38

answers:

1

I'm developing a program which allows users to input some information which then gets stored and dynamically creates an image based on it.

I was going to use the Entity Framework to do the work with the data, but then I obviously need a way to generate the image. My thinking was that the "correct" way to do this was to somehow extend the data entity to include a function call like "CreateImage", or alternatively, to create a separate class not in the EF called "DataImage" which would have a "generate" method.

Extending the EF seems the "pure" way to do this, but I'm not sure how or if it's more practical than using the separate class.

Any thoughts on the best way to do this and how to do it using EF?

+2  A: 

Putting this functionality in the EF would be a major violation of SRP. Breaking SRP has cascading negative effects as your application grows.

The approach you most likely want to take instead is a totally separate, encapsulated image generation service which takes interfaces that your EF entities implement. This decouples your image service from your data access completely; you get complete testability and zero dependencies right away.

Rex M
Thanks Rex,I'm quite new to EF and just wondering about what the interfaces are that are implemented (I used the tool to create the edmx from the database). If you can point me at any resources...
Tim Almond