4

I have a strange situation. I have created a data model visually and generated a database from it. This project is referenced by two projects:

  • ASP .NET application.
  • WinForms application.

The ASP .NET application deals directly with the database while I need the WinForms application to interact with the database via the Web application.

I have created a page called API.aspx and use HTTP POST to send values and get results in XML.

However, since the WinForms application still needs to use the data model classes, I am running into issues using them without creating a database object.

What is a good strategy to use in this scenario?

0

2 Answers 2

2

If you have implemented your code with loose coupling (See the Repository Pattern), then you could create a database stub that will return dummy data (or in memory data) until you are ready to plug in the actual EF framework.

This is generally good practice to create a clean separation of concerns.

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

4 Comments

Does EF offer any built-in tools for such scenarios? I am trying to look at code-first to see if that gives me more flexibility with handling of classes in the context of a database or just in memory.
@RaheelKhan No, this scenario actually abstracts the ORM away. However, you could use the POCO's outside the context if you really wanted. The problem would only come at the points that you want to interact with the db...Here is an article I found in a quick google about mocking EF contexts: nogginbox.co.uk/blog/mocking-entity-framework-data-context
To the anonymous downvoter. Could you please explain what you do not like so that I can adapt my answer appropriately?
Hi Justin, sorry - I don't even remember looking at this question earlier - I can only guess that I touched the downvote accidentally when viewing the site on my iPad. Can you edit your answer somehow so that I can remove the downvote. Really sorry about that.
0

This sounds like a candidate for an SOA implementation, rather than having the windows forms app communicate directly with the web application:

2 Comments

Yes I agree, but that abstraction can be done at a later stage. This is a prototype.
Plus I need to support an offline mode as well in the desktop application.

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.