mirror of
https://github.com/fergalmoran/EFCore.NamingConventions.git
synced 2025-12-22 09:38:21 +00:00
Check name for null before attempting to rewrite
And annotate the plugin for nullability. Fixes #179
This commit is contained in:
@@ -468,6 +468,24 @@ public class NameRewritingConventionTest
|
||||
Assert.Null(entityType.GetTableName());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Foreign_key_without_name_because_over_view()
|
||||
{
|
||||
var model = BuildModel(b =>
|
||||
{
|
||||
b.Entity<Blog>();
|
||||
b.Entity<Post>().ToView("posts_view");
|
||||
b.Entity<Post>().HasOne(x => x.Blog).WithMany().HasForeignKey(x => x.BlogId);
|
||||
});
|
||||
|
||||
var postEntityType = model.FindEntityType(typeof(Post))!;
|
||||
Assert.Null(postEntityType.GetTableName());
|
||||
Assert.Collection(
|
||||
postEntityType.GetForeignKeys().Select(fk => fk.GetConstraintName()),
|
||||
Assert.Null,
|
||||
Assert.Null);
|
||||
}
|
||||
|
||||
private IEntityType BuildEntityType(Action<ModelBuilder> builderAction, CultureInfo culture = null)
|
||||
=> BuildModel(builderAction, culture).GetEntityTypes().Single();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user