ASP. NET mvc4 + Entity Framework instance (KE leyi message board, with source code)

Source: Internet
Author: User

Previous Article about ASP. NET mvc4ArticleUsing ajax in ASP. NET mvc4 is also an example of a message board, which describes how to use Ajax on the mvc4 platform. Http://www.keleyi.com/a/bjac/781ba7719ce323f.htm

Based on the above example, this article adds data storage access, using the currently popular Entity Framework technology.

Keleyi is a simple message board and a good example of learning ASP. net mvc. The database uses SQL Server. The project adopts a layered architecture and MVC model. The data access technology uses Entity Framework, and the front-end uses Ajax andProgramBackground interaction,Source codeDownload downloads from http://keleyi.codeplex.com.

The keleyi project can run with Visual Studio 2010 (mvc4 installed), or Visual Studio 2012 open, the installation method can refer to: http://www.keleyi.com/a/bjac/2916901353b081f1.htm

Currently, the keleyi project uses mvc4 of. Net 4.0 to Implement Message submission and background Message Management (public or hidden messages) at the front end. This instance is also updated. For more information, visit the http://www.keleyi.com

Yes run:

The following section describes how to access the database using Entity Framework.Code:

 Using System. componentmodel. dataannotations. Schema;  Using  System. Data. entity. modelconfiguration;  Namespace  Keleyi. com. efdal. Models. Mapping {  Public   Class Keleyi_messagemap: entitytypeconfiguration <keleyi. com. model. messageinfo> {  Public  Keleyi_messagemap (){  //  Primary Key  This . Haskey (t =>T. Kid );  //  Properties  This . Property (t => T. kcontent). hasmaxlength (  2000  );  This . Property (t => T. ktitle). hasmaxlength (  100  );  This . Property (t => T. kemail). hasmaxlength (  100  ); This . Property (t => T. KQQ). hasmaxlength (  50  );  //  Table & Column mappings www.keleyi.com  This . Totable ( "  Keleyi_message  "  );  This . Property (t => T. Kid). hascolumnname ( "  Kid  " );  This . Property (t => T. kaddtime). hascolumnname ( "  Kaddtime  "  );  This . Property (t => T. kcontent). hascolumnname ( "  Kcontent  "  );  This . Property (t => T. ktitle). hascolumnname ( "  Ktitle  " );  This . Property (t => T. kemail). hascolumnname ( "  Kemail  "  );  This . Property (t => T. KQQ). hascolumnname ( "  KQQ  "  );  This . Property (t => T. kisshow). hascolumnname ( "  Kisshow  " );}}} 

This article forwarding from Ke leyi: http://www.keleyi.com/a/bjac/4064796bf1f324c8.htm

Related Article

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.