Is there any possible configuration for setting the column order of the database in the first approach of the entity structure code.?
My entire set of objects should have some common fields for storing recordinfo
public DateTime CreatedAt { get; set; } public int CreatedBy { get; set; } public DateTime ModifiedAt { get; set; } public int ModifiedBy { get; set; } public bool IsDeleted { get; set; }
I want to keep these fields at the end of the table. Is there any possible EF configuration that I can use to configure it, and not to save these fields at the end of my model class.
, Entity Framework 6, EF Core.
API .
, System.ComponentModel.DataAnnotations ColumnAttribute. , , .
System.ComponentModel.DataAnnotations
ColumnAttribute
[Column("CreatedAt", Order=0)] public DateTime CreatedAt { get; set; } [Column("CreatedBy", Order=1)] public int CreatedBy { get; set; }
, "" .
: http://www.entityframeworktutorial.net/code-first/column-dataannotations-attribute-in-code-first.aspx
Fluent API OnModelCreating DbContext:
OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder) { //Configure Column modelBuilder.Entity<EntityClass>() .Property(p => p.CreatedAt) .HasColumnOrder(0); }
: http://www.entityframeworktutorial.net/code-first/configure-property-mappings-using-fluent-api.aspx
, , .
:
using System.ComponentModel.DataAnnotations.Schema;
[DisplayColumn("Name" , Order = 1)] public int UserName { get; set; }
: cloumn arder , , , , , : 0 !
Source: https://habr.com/ru/post/1674166/More articles:Bar graph using Excel function FREQUENCY - excelCreating an array of box sizes in Excel - excelAngular 4 router Error: do not activate an already activated outlet - angularUploading images to React with Webpack - imageMicroservice Architecture: Chatty Services or Data Duplication - architectureHow to check if an application pool exists or not in IIS using PowerShell and the web administration module? - powershellJoin futures with limited concurrency - rustHow to set application pool application id using web administration module in powershell? - powershellHighcharts multiple x axes hidden when scaling - javascript* 13 prematurely closed connection up while reading the response header from the upstream - python-3.xAll Articles