3

I'm building a program which has two options: an offline and an online storage option. The online stuff isn't a problem, never has been and probably never will be. To make things a little more simple, I am using the Entity Framework with my online database to do all of my CRUD.

The offline option is where I'm having a problem. I tried adding a local SQL install as part of the install package, but it was failing on certain computers depending upon which version of SQL I was using, some people just couldn't install it at all... honestly, I don't want to be going through that just to get people to install the program. I want to do two things:

1) Store the data. I'm currently thinking Linq to XML is my best bet with nothing extra to install, but is there any way to map the entities to classes within the program that would take care of the XML CRUD?

2) Sync the data. I'm thinking I'll use the Sync Framework, but again, with no normal database in the background, it's a bit of a pain.

Any help/advice/comments very welcome, if there's a much easier way of doing all this, please let me know.

2
  • Will an installation be allowed to sometimes run online and sometimes offline? Commented Nov 10, 2010 at 22:40
  • Yes. The installation is designed to run offline but with online synchronisation. The sync bit I already have one way to get working, but would like something a bit more concrete. Commented Nov 10, 2010 at 22:44

1 Answer 1

2

I'm glad to hear you've got something figured out for the syncing logic. That's the bit that would keep me up at night. GUIDs are your friend in a situation like this.

And I've never attempted to use 1 ObjectContext targeted at different datasources. Maybe you can pull off something slick using OLEDB as your provider. I'd go a little down that road. But I suspect you'll find it's more trouble than it's worth.

I recommend following the Repository Pattern. Then you can just implement a XMLRepository and a SQLRepository. This may mean some borderline double coding. But queries against XML versus a database have their own concerns. So, depending on your specifics, I think violating the DRY principle may be justified.

Also, and I acknowledge this is completely subjective, it strikes me that the Entity Framework is overkill for a relational model that can be easily persisted in XML. I'm just curious if you considered using LINQ-to-SQL. And if so, what convinced you to go the way of EF?

Sign up to request clarification or add additional context in comments.

1 Comment

It was actually the use of Linq-to-SQL that gave me the idea of using EF. Using Linq to SQL for the online db was a piece of cake, and knowing that you could define a db connection later using a conceptual EF seemed even better to me, like maybe I could consolidate the two at a later point? But it seems that good oldfashioned "Code it twice" seems to be the way to go with two persistant data stores. All's fun in coding!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.