I want to use entity framework to manage access to data. Windows applications will be invoking a WCF service on a server, which will then use entity framework to read and write to the database.
Can anyone point me in the right direction on how to approach this? Maybe some sample code to get started?
Issues that come to mind but which I am not sure how to address are:
1) Concurrency – each user needs to have a separate context to which he can make the changes and then save them?
2) Connections – will the database be flooded with connections if we have many contexts?
3) Will the WCF service be able to cope with this load?
Thanks!
I suggest you take a look here:
http://msdn.microsoft.com/en-us/magazine/ee321569.aspx
There are some nice patterns you can use, esspeccially self-tracking entities.
1) In WCF (by default, you can change this), each call to the service, generates another instance of the service. So each user will have his own context, but per call, so i guess you need a little more. Im not sure, that you mean, that each user should have its own context as an instance of the EF context class, or that they should connect via different creadentials, to give them access to different data…
2) What do you mean by flooded? If 1000 users will update the database in 1 second, then yea, the db will have to handle 1000 queries. But there is something called connection pooling, just google it.
3) What kind of “load” do you mean? As “How many users will i be able to handle with WCF in this scenario”?