views:

23

answers:

2

Hello folks, i've just started a new asp.net project which could increase fastly(a small erp-system for our company). So i thought it would be a good idea to split at least the model from the view/controller(the asp.net project). Because it could be that i need to access some classes and the database from a windows app in future, i dicided to put the Model into its own Project. What Visual Studio 2005 Professional Projecttype is most suitable for this requirement and why?

  • SqlServerProject (DB is MS Sql Server 2005 EP)
  • Class Library
  • Web Service Application
  • Database project
  • no separate Project/other(keep in mind VS 2005 has no ASP.NET MVC-Project)

Thanks

+1  A: 

You should keep your model in a class library, the same goes for your data access layer. The database itself can either be modeled from within Sql Server Managment Studio or a Database Project.

The SqlServerProject is something different, it's for writing CLR procedures for SQL Server.

Johannes Rudolph
Thanks. Should the model and the data access layer be in separate projects or in the same?
Tim Schmelter
Sometimes it is impossible to separate the two (e.g. when using Linq2Sql). In general, I would prefer separating the two because having them together will make your model an anemic databag for your data access layer.
Johannes Rudolph
I will start with one project for both because i dont want to complicate the access before i really started but i keep that in mind.
Tim Schmelter
+1  A: 

Like Johannes said, you should build your model in a class library.

Only thing to add is, you really don't even need to create another project to do this unless you want to. You can add a class library to the same ASP.NET Web Application project by adding the App_Code folder to your project and creating new class library(s) in that folder.

Just right click on your project and select Add ASP.NET Folder->App_Code. Once that folder is created you can create your class library(s) there(BLL & DAL). These will be compiled to DLLs when you build the project that can be included in other projects as well.

One more thing as to the WHY of using a class library, it is so that you can build a class(DLL) with public methods/properties that can be easily included/used with another application down the road.

jaywon
Thanks for the app_code hint and the "why". But its still unclear why i should prefer the app_code variant. What about Source Safe integration? Do i need a separate Project in VSS? Would it be easy to change the code of the model and every project that uses the model would get the new version?
Tim Schmelter
@Tim, Really, my answer was agreeing that it should be a class library. It was just a suggestion as to another option you had to keep it in the same project. If you are going to use it in multiple projects as well as the VSS considerations it probably is a good idea to make it it's own project. It should be easier to maintain that way as it's own entity.
jaywon
@jaywon: Sorry, i misunderstood that.So i should'nt add the project to the same solution as the main project? I will mark Johannes as answer because he was faster, but thanks anyway for your assist.
Tim Schmelter