0

I have to build 3 MVC web applications using Entity Framework (www.company1.com www.company2.com www.company3.com). The websites will all access the same sql server database, but will be slightly different in their own way (appearance, data etc). More than likely all three MVC applications will be hosted on the same server, but binded to different domain names.

Currently in Visual Studio, I have the following structure to my solution

  • Domain Classes
  • Data Layer
  • Services
  • Repositories
  • MVC App 1
  • MVC App 2
  • MVC App 3

I would have preferred to have used Area's, but I can't because each site has to be assigned it's own different domain name. I guess I am just seeking assurances that architecting my solution this way won't cause any difficulties for me when the applications are published. I am slightly paranoid about the sites sharing the dbContext or something, however, I know that many sound silly.

It would be great if anyone could advice me if this all looks ok, or maybe there is a better way to do what I am asking.

Thanks as ever.

tcode
  • 5,055
  • 19
  • 65
  • 124
  • 1
    This is fairly normal behavior. Multiple applications using the same data source. Simultaneous connections to the db is also covered in this [SO post](http://stackoverflow.com/questions/3615788/simultaneous-connections-to-sql-server-using-the-same-name-and-password-is-ther) – Stokedout Jan 04 '13 at 11:24

2 Answers2

1

As long as you have a good way of validating and differentiating the sites in the Datalayer, than you will not have to worry. How are you validating this?

I also would always put simulair code and pages in a main project so you do not copy parts or even whole pages for different sites. (My guess is that you already did so)

Kevin Hendricks
  • 785
  • 1
  • 8
  • 36
  • I am not sure what you mean by "validating and differentiating the sites in the Datalayer", why would I need to do this? All three sites will use the exact same database. With regards re-use of code over the three sites, my Service Layer will help with this. – tcode Jan 04 '13 at 11:24
  • What I mean is, how do you validate that site a can not access data from site b. I seen developers using the URL before which is not the best approach in my idea. A more static unchangeable reference in the seperate project might be more safe. So you can than safely validate that site a is only allowed to get data from the DB table which is actually owned by Site A – Kevin Hendricks Jan 04 '13 at 11:29
  • I see what you mean now Kevin, and it's a good point. This validation will be handled in my code. – tcode Jan 04 '13 at 11:51
1

I've done the same thing for the same reason. I have a CMS that must reside at a different host-name. It works fine.

The trick is finding ways of sharing code across the MVC apps. To avoid circular dependencies and such, I created one more MVC app to hold things such as my controller that serves up image files, HTML Helpers that can be re-used, etc.

Faust
  • 15,130
  • 9
  • 54
  • 111