-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3469
- Loading branch information
Showing
4 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
samples/core/Modeling/EntityProperties/DataAnnotations/ColumnOrder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.EntityProperties.DataAnnotations.ColumnOrder | ||
{ | ||
internal class MyContext : DbContext | ||
{ | ||
public DbSet<Employee> Employees { get; set; } | ||
} | ||
|
||
#region snippet_ColumnAttribute | ||
public class EntityBase | ||
{ | ||
[Column(Order = 0)] | ||
public int Id { get; set; } | ||
} | ||
|
||
public class PersonBase : EntityBase | ||
{ | ||
[Column(Order = 1)] | ||
public string FirstName { get; set; } | ||
|
||
[Column(Order = 2)] | ||
public string LastName { get; set; } | ||
} | ||
|
||
public class Employee : PersonBase | ||
{ | ||
public string Department { get; set; } | ||
public decimal AnnualSalary { get; set; } | ||
} | ||
#endregion | ||
} |
43 changes: 43 additions & 0 deletions
43
samples/core/Modeling/EntityProperties/FluentAPI/ColumnOrder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.EntityProperties.FluentAPI.ColumnOrder | ||
{ | ||
internal class MyContext : DbContext | ||
{ | ||
public DbSet<Employee> Employees { get; set; } | ||
|
||
#region snippet_HasColumnOrder | ||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Employee>(x => | ||
{ | ||
x.Property(b => b.Id) | ||
.HasColumnOrder(0); | ||
x.Property(b => b.FirstName) | ||
.HasColumnOrder(1); | ||
x.Property(b => b.LastName) | ||
.HasColumnOrder(2); | ||
}); | ||
} | ||
#endregion | ||
} | ||
|
||
public class EntityBase | ||
{ | ||
public int Id { get; set; } | ||
} | ||
|
||
public class PersonBase : EntityBase | ||
{ | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
} | ||
|
||
public class Employee : PersonBase | ||
{ | ||
public string Department { get; set; } | ||
public decimal AnnualSalary { get; set; } | ||
} | ||
} |