A few days ago is open a question, about how to do their own thinking a lot, but after all did not do projects do not know whether these ideas have no need, also do not know whether can be achieved, but Deng said "stones" bar. This period of time saw some bloggers the article harvest is very big, especially @kencery, according to gourd painting scoop open write.
I. BASIC FRAMEWORK
First of all, the basic framework, all of a sudden 7 projects looked very messy, my understanding is M, V, C 3, M is the data carrier, V is the user to see the attempt, C mainly coordinated control and user interface-related operations, and data processing, the operation of the database to the DAL, BLL to do. The whole idea is that view is the interface that the user sees; Controller is responsible for coordinating the user's actions, looking for the business logic layer when the data is needed or processed; the business logic layer needs to access the database and then to the data access layer; The data access layer interacts with SQL Server through EF The medium of data interaction between layers is model.
Here IBLL and Idal are interfaces, functions in the BLL and Dal in the implementation, seemingly redundant, in fact, still very useful place. One is that the interface only implements a method definition that looks straightforward; the other is that as long as the interface remains unchanged, the calls between the items will not change, no matter how the implemented code is written.
Ii. Establishment of the project
1, the establishment of Web projects.
Select the template->visual c#->web->asp.net Web application.
Here and there is a significant change in the vs2012, WebForm, MVC, API, and so do a template. As shown in figure
What if you want to develop as before? Point Open web-> Visual Studio 2012 is not familiar with the feeling of coming back again.
We still choose Web->asp.net Web application OK here.
Here you choose MVC (you can choose to add WebForm, API references, and hash out several previous projects.) Only MVC is selected here, authentication is selected for the personal user account, which adds the latest ASP.net identity code (in fact, it doesn't matter what you choose, you don't intend to use asp.net identity, user management or do it yourself, It was chosen to see how Microsoft's code was written.
2. Establishment of 6 other projects
Right-click on solution-> add-> New Project
Project Type Select->visual c#–>windows-> class Library.
This creates six other projects.
After completion, the framework is as follows:
Iii. references between projects
Add a reference between projects after the project is established.
Right-click on a reference to a Web project, select a solution-> Project add Ninesky.models, Ninesky.common, NINESKY.IBLL, NINESKY.BLL references
Sequentially: Idal Add Ninesky.models Reference
Dal add ninesky.modles, Ninesky.idal references
IBLL Add Ninesky.modles Reference
BLL add Ninesky.models, Ninesky.idal, Ninesky.dal, NINESKY.IBLL references
In addition, the DAL models to add a entityframework reference to the NuGet. method is the project reference right-click to select the management NuGet package. Select the online->nuget.org->entityframework in the pop-up window and then click Install to complete the installation automatically.
The frame is finished. Here the Web project represents the V and C in MVC. The Modle project represents M. The common project prepares to write public methods. The other 4 projects are the data data access layer and the business logic layer in the three-tier architecture, and the interface is used in addition. The next time you can finally write code.