1

I am currently working on a ASP.NET project in .NET framework 4.5, using Entity Framework, and working in Visual Studio Express 2012 for web. At this point, I have created a lot of models, context and controllers.

I have also made some classes for importing huge amounts of data into the database from data files. However, at this point it has become clear that the actual import should probably be done through a service or console application.

How do I go about separating the importer code logic from the current project, while retaining all the dependencies to the MVC framework, to put it into a console application project?

  • Do I just make the new project depend on the old one?
  • The connection string for the database is configured through web.config, and managed by the internal context logic in the old project. How do I use this is the console application?

1 Answer 1

3

Ideally, your business logic is separate from your UI, which in this case is your ASP.NET website. Within Visual Studio, I would separate all that data logic into it's own project that's set up as a class library, have the web project depend on/reference it. Then you can add another console/service application project to the solution and reference the very same objects.

http://msdn.microsoft.com/en-us/magazine/dd419654.aspx http://en.wikipedia.org/wiki/Separation_of_concerns

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

3 Comments

Yup, and that is essentially what I want to do. And it seems to be working just fine. I did, however, need to copy the web.config file into the console application project, renaming it app.config. Is there a way to share config files between projects?
Great tip, though, adding as link doesn't work in my case, as it is necessarily called web.config in one location and app.config in the other. There doesn't seem to be an option to rename the link.

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.