mirror of
https://github.com/fergalmoran/EFCore.NamingConventions.git
synced 2025-12-22 09:38:21 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(EFCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EFCore.NamingConventions\EFCore.NamingConventions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
41
EFCore.NamingConventions.Test/NamingConventionsTest.cs
Normal file
41
EFCore.NamingConventions.Test/NamingConventionsTest.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Xunit;
|
||||
|
||||
namespace EFCore.Naming.Test
|
||||
{
|
||||
public class NamingTest
|
||||
{
|
||||
[Fact]
|
||||
public void Table_name_is_rewritten()
|
||||
{
|
||||
using var context = new TestContext();
|
||||
var entityType = context.Model.FindEntityType(typeof(Blog));
|
||||
Assert.Equal("blog", entityType.GetTableName());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Column_name_is_rewritten()
|
||||
{
|
||||
using var context = new TestContext();
|
||||
var entityType = context.Model.FindEntityType(typeof(Blog));
|
||||
Assert.Equal("id", entityType.FindProperty("Id").GetColumnName());
|
||||
Assert.Equal("full_name", entityType.FindProperty("FullName").GetColumnName());
|
||||
}
|
||||
|
||||
public class TestContext : DbContext
|
||||
{
|
||||
public DbSet<Blog> Blog { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
=> optionsBuilder
|
||||
.UseInMemoryDatabase("test")
|
||||
.UseSnakeCaseNamingConventions();
|
||||
}
|
||||
|
||||
public class Blog
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user