locked
Additing a 2nd project RRS feed

  • Question

  • User2043512157 posted

    Hi,

    I have a c# web solution that until recently had a single project.  I want to add a 2nd project.

    At present the dtabase associated with project 1 is in the app_data folder of project 1.

    The 2nd project also needs to use the resources of project 1 - how do I go about structuring this?

     

     

    Saturday, May 14, 2011 5:36 AM

Answers

  • User-909741850 posted
    you can create a class in the database project to access the database, then you can reference it in the first project to get access.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 15, 2011 6:35 PM
  • User-952121411 posted

    Typically the layer that contains the App_Data folder is the UI layer, and I don't like to have projects need a reference to it (start to get into cyclical references). Rather I prefer the UI layer to require the references of layers below it.

    I think it might be possible to extract out the database file in your App_Code, place it in a class library project that has Data Access (DAL) type behavior and then have your UI web app layer reference this new layer. The problem is I have always found it to be a bit tricky making any other file types besides other .dlls be referenced and dependencies of a class library project and get successfully output when building. I prefer the single binary to be the output when creating a class library project if possible.

    I am not savvy to the nth degree on local (i.e. SQL Compact) databases within the web app (more familiar with full on SQL databases), and there might be layering guidelines specific to this setup. If there is non-data access logic and not associated with needing access to that database, then that type of code could easily be refactored into a class library on its own referenced by the UI layer. However if it was me in the scenario you are describing, I would probably leave the database where it was and just refactor the newly needed code into their own set of classes within the same layer.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 16, 2011 2:26 PM

All replies

  • User-909741850 posted

    In Visual Studio, Select File -- Add -- New Project.

    Enjoy!

    Saturday, May 14, 2011 6:34 AM
  • User2043512157 posted

    Can Ireference the database though?

    Saturday, May 14, 2011 7:40 AM
  • User-909741850 posted
    you can create a class in the database project to access the database, then you can reference it in the first project to get access.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 15, 2011 6:35 PM
  • User-952121411 posted

    Typically the layer that contains the App_Data folder is the UI layer, and I don't like to have projects need a reference to it (start to get into cyclical references). Rather I prefer the UI layer to require the references of layers below it.

    I think it might be possible to extract out the database file in your App_Code, place it in a class library project that has Data Access (DAL) type behavior and then have your UI web app layer reference this new layer. The problem is I have always found it to be a bit tricky making any other file types besides other .dlls be referenced and dependencies of a class library project and get successfully output when building. I prefer the single binary to be the output when creating a class library project if possible.

    I am not savvy to the nth degree on local (i.e. SQL Compact) databases within the web app (more familiar with full on SQL databases), and there might be layering guidelines specific to this setup. If there is non-data access logic and not associated with needing access to that database, then that type of code could easily be refactored into a class library on its own referenced by the UI layer. However if it was me in the scenario you are describing, I would probably leave the database where it was and just refactor the newly needed code into their own set of classes within the same layer.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 16, 2011 2:26 PM