EntityFramework-Based Domain-driven design practices [continued later]: Use Cases of domain-driven design practices based on EF 4.3.1 Code First

Source: Internet
Author: User
Tags to domain

Address: http://www.cnblogs.com/daxnet/archive/2012/04/16/2452660.html

 

 

Two years ago, I published a series of articles in my blog titled EntityFramework-driven design practices in the field, which also attracted the attention of many readers. After summing up the series of articles, this part of content has never been updated. Now, Entity
Stable version of the Framework (that is, the Stable version, not the Entity Framework
Version 5) 4.3.1 has been gradually applied to various. NET projects. To demonstrate the Entity Framework 4.3.1 Code
The First programming mode and some other. NET technology applications in the field-driven design practices, I re-adopt the classic layered architecture (similar to Microsoft
The difference between NLayerApp and CQRS is that it implements a case program: Byteart
Retail. In this case, the implementation of warehousing does not use nhib.pdf, but uses Entity Framework 4.3.1 Code.
First. Although this case fully demonstrates the application of. NET Technology in enterprise-level programs, Entity
Framework is indeed one of its highlights. Therefore, I will also compile this article about this case in the original EF series.

Case Overview

Byteart Retail demonstrates the application of Microsoft. NET technology and field-driven design concepts in software design, architecture, and practice based on the online sales business of laptops. Prior to Byteart Retail, the open-source community also had some practical cases of field-driven design, such as Microsoft
Domain-Oriented NLayered Application Architecture, Tiny Library for CQRS Architecture Model
CQRS. Compared with these cases, Byteart
Retail has a certain degree of similarity and comparability in field-driven practice guidance, but it pays more attention to the combination of Microsoft. NET technology and field-driven design. For example, Byteart
The Retail case shows the implementation of Code First mode based on Entity Framework 4.3.1.
Framework Warehousing Design enables the domain model object to be fully designed as a POCO object without relying on any other technical Framework. Therefore, in the selection and use of warehousing, it can achieve "seamless replacement ". On the other hand, the design of the domain model is also more sophisticated. The design of entities and value objects and the division of aggregation are all closely integrated with the system business and more mature than other demonstration cases. From the business logic perspective, Byteart
Retail provides the following functions:

  1. Browse laptop Products
  2. Customer Account registration and basic information query and Modification
  3. Laptop details Query
  4. The customer adds laptop products to the shopping basket.
  5. Shopping Basket item project management
  6. Create a sales order from the basket
  7. Confirm and query the sales order
  8. Sales order details Query

The example demonstrates the following. NET technology and development skills:

  1. Microsoft Entity Framework 4.3.1 Code
    First
  2. ASP. net mvc 3
  3. WCF
  4. Microsoft Patterns & Practices Unity
    Application Block
  5. Use AutoMapper to map DTO to domain objects
  6. T4 Automatic Code Generation

Download case

Please[Click here]Download all source code and Visual Studio in this case
Solution file of 2010.

System Requirements

Development Environment: Visual Studio 2010 Professional/Ultimate with SP1, ASP. NET
MVC3. Other Assembly references are in the packages directory of the compressed package. Therefore, you do not need to download and install other components online.

Installation and deployment

Database

Byteart Retail uses Microsoft SQL Server
2008 serves as the background database. First, modify the web. config file under the ByteartRetail. Services Project to configure the database link string:

Then, follow the"Program startup"To start the ByteartRetail. Web project. At this time, the Entity
Framework creates a database named ByteartRetail based on the preceding connection string.

Finally, open SQL Server Management
Studio. Run the ByteartRetailData. SQL file in the SQL directory of the compressed package to import the required test data to the ByteartRetail database.

Note: although this database deployment and initialization method can circumvent "Model compatibility cannot be checked because
Database does not contain model
Metadata. "error, but it is still not an ideal deployment method. Here, we use this method for the time being to let the case run first. In the future, I will find a more reasonable method and update this part of content.

Program startup

Use Visual Studio to open the solution and complete compilation, right-click a. svc file in the ByteartRetail. Services Project, and select View
The in Browser option starts the WCF Service. After running the ByteartRetail. Web project, the main interface is displayed.

Design Overview

Here I will first paste some of the designed class diagrams so that readers can refer to them when viewing the source code.

Domain Model

Entity Framework-based Warehousing Design (Omitted attributes and methods)

Protocol Design

Enterprise Application Architecture Model Reference

This case roughly involves the following Enterprise-level application architecture models, which are also listed for your reference.
Application Architecture, Core J2EE Patterns, and other books.

  • Domain Model
  • Unit Of Work
  • Repository
  • Data Transfer Object
  • Client Session State
  • Layer Supertype
  • Separated Interface
  • Value Object
  • Business Delegate
  • Service Locator
  • Transfer Object aggreger

Summary

We warmly welcome readers who love Microsoft. NET technology and field-driven design to discuss this case in depth. If you have any questions or suggestions, please leave a message to reply.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.