EFCore.NamingConventions provides the following naming conventions for Entity Framework Core tables and columns.
full_name
fullname
fullName
FULLNAME
By default, EF Core maps classes and properties exactly to tables and columns names respectively.
In the OnConfiguring
method, you can use any of the above-mentioned naming conventions by calling the respective method. The following uses the snake case naming conventions by calling the UseSnakeCaseNamingConvention
extension method.
public class BookStore : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseSqlServer(@"Data Source=(localdb)\ProjectsV13;Initial Catalog=BookStoreDb;")
.UseSnakeCaseNamingConvention();
}
public DbSet<Author> Authors { get; set; }
public DbSet<Book> Books { get; set; }
}
Let's run your application again and you will see that this time all the tables and columns are in snake case naming convention.