-
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.
Add documentation for TPT configuration.
Fixes #1979
- Loading branch information
1 parent
6449d9e
commit 61f88b9
Showing
3 changed files
with
100 additions
and
14 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
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,49 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using System; | ||
|
||
namespace EFModeling.FluentAPI.TPTConfiguration | ||
{ | ||
public class MyContext : DbContext | ||
{ | ||
public MyContext(DbContextOptions<MyContext> options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
#region TPTConfiguration | ||
modelBuilder.Entity<Blog>().ToTable("Blogs"); | ||
modelBuilder.Entity<RssBlog>().ToTable("RssBlogs"); | ||
#endregion | ||
|
||
#region Metadata | ||
foreach (var entityType in modelBuilder.Model.GetEntityTypes()) | ||
{ | ||
var tableIdentifier = StoreObjectIdentifier.Create(entityType, StoreObjectType.Table); | ||
Console.WriteLine(entityType.DisplayName() + $"\t\t{tableIdentifier}"); | ||
Console.WriteLine(" Property\tColumn"); | ||
foreach (var property in entityType.GetProperties()) | ||
{ | ||
Console.WriteLine(" " + property.Name.PadRight(10) + "\t" + property.GetColumnName(tableIdentifier.Value)); | ||
} | ||
Console.WriteLine(); | ||
} | ||
#endregion | ||
} | ||
} | ||
|
||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
} | ||
|
||
public class RssBlog : Blog | ||
{ | ||
public string RssUrl { get; set; } | ||
} | ||
} |