Add database entity annotations for the EF framework using the T4 template

Source: Internet
Author: User

There is a workaround on the internet as follows:

Http://www.cnblogs.com/stone_w/archive/2012/10/25/2738345.html

But I tried. It's too much trouble, and once the EF is rebuilt and rebuilt.

Later I queried the information, can use the T4 template to solve this problem.

1. Download file getsummery.ttinclude, here I have provided, everyone to download: download 2. Unzip the files we downloaded and put the extracted files into the solution3. Modify the following app.config, add a connection string:
    1. <add name= "myconn" connectionstring= "data source=.; Initial catalog=db;user id=sa;password=xxx; " providername="System.Data.SqlClient" />
4. Modifications model.tt, add code at the top location:

    1. <#@ include file="getsummery.ttinclude" #>

5. (Insert class Comment, optionally add) insert above code fragment <#=codeStringGenerator.EntityClassOpening(entity)#> (around 28 lines)

    1. <summary>
    2. <#= gettablesummery (code. Escape (Entity) #>
    3. </Summary>

6. (add field comment) in code snippet: <#=codeStringGenerator.Property(edmProperty)#>Above (76 rows or so) Insert:
    1. <summary>
    2. <#= getcolumnsummery (code. Escape (entity), code. Escape (edmproperty) #>
    3. </Summary>

Note: The previous comment symbol///cannot be less

Here, basically done, to refresh your entity model EDMX file, you will find the field comments are automatically added.

Reference Source Address: http://jeffblog.sinaapp.com/archives/501

Add database entity annotations for the EF framework using the T4 template

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.