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