Mego Development Documentation-Database modeling

Source: Internet
Author: User

Database modeling

We also provide some additional features for customizing the data structure of the database.

Table mappings

By default, the framework uses the CLR type name as the table name for the actual database and can be used to enforce table names when they are inconsistent.

[Table("blogs")]public class Blog{    public int BlogId { get; set; }    public string Url { get; set; }}
Column Mappings

By default, the framework uses the CLR property name as the column name for the actual database, which can be used to enforce column names when they are inconsistent.

public class Blog{    [Column("blog_id")]    public int BlogId { get; set; }    public string Url { get; set; }}
Data type

The data type refers to the database-specific type of the column to which the attribute is mapped.

public class Blog{    public int BlogId { get; set; }       [Column(nameof(Url), "varchar(200)")]    public string Url { get; set; }    [Column(nameof(Rating), "decimal(5, 2)")]    public decimal Rating { get; set; }}
Computed columns

A computed column is a column whose value is computed in the database. Computed columns can use other columns in the table to calculate their values, and some databases also support computed column persistence, which can also be declared. Properties for computed columns are not sent to the database at the time of submission.

public class Person{    public int PersonId { get; set; }    public string FirstName { get; set; }    public string LastName { get; set; }    [Computed("[LastName] + ‘, ‘ + [FirstName]")]    public string DisplayName { get; set; }}

Mego Development Documentation-Database modeling

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.