-
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 mapping two properties to the same column when …
…using TPH Fixes #529
- Loading branch information
1 parent
00f8660
commit 9b8ec19
Showing
8 changed files
with
128 additions
and
56 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
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,29 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.FluentAPI.DefaultDiscriminator | ||
{ | ||
public class MyContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
#region DiscriminatorConfiguration | ||
modelBuilder.Entity<Blog>() | ||
.Property("Discriminator") | ||
.HasMaxLength(200); | ||
#endregion | ||
} | ||
} | ||
|
||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
} | ||
|
||
public class RssBlog : Blog | ||
{ | ||
public string RssUrl { get; set; } | ||
} | ||
} |
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,38 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.FluentAPI.NonShadowDiscriminator | ||
{ | ||
#region NonShadowDiscriminator | ||
public class MyContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Blog>() | ||
.Property("Discriminator") | ||
.HasMaxLength(200); | ||
|
||
modelBuilder.Entity<Blog>() | ||
.HasDiscriminator(b => b.BlogType); | ||
|
||
modelBuilder.Entity<Blog>() | ||
.Property(e => e.BlogType) | ||
.HasMaxLength(200) | ||
.HasColumnName("blog_type"); | ||
} | ||
} | ||
|
||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
public string BlogType { get; set; } | ||
} | ||
|
||
public class RssBlog : Blog | ||
{ | ||
public string RssUrl { get; set; } | ||
} | ||
#endregion | ||
} |
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,37 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EFModeling.FluentAPI.SharedTPHColumns | ||
{ | ||
#region SharedTPHColumns | ||
public class MyContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Blog>() | ||
.Property(b => b.Url) | ||
.HasColumnName("Url"); | ||
|
||
modelBuilder.Entity<RssBlog>() | ||
.Property(b => b.Url) | ||
.HasColumnName("Url"); | ||
} | ||
} | ||
|
||
public class BlogBase | ||
{ | ||
public int BlogId { get; set; } | ||
} | ||
|
||
public class Blog : BlogBase | ||
{ | ||
public string Url { get; set; } | ||
} | ||
|
||
public class RssBlog : BlogBase | ||
{ | ||
public string Url { get; set; } | ||
} | ||
#endregion | ||
} |