question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EFCore.NamingConventions not working with Abp

See original GitHub issue
  • Abp package version: 5.10.1
  • base framework: .Net Core
  • Steps needed to reproduce the problem:
  • Download a aspnetboilerplate template
  • Integrate postgres
  • Use UseSnakeCaseNamingConvention in *DbContextConfigurer
  • In *DbContext add modelBuilder.ChangeAbpTablePrefix<Tenant, Role, User>("", "abp"); in OnModelCreating method
  • Then add-migration Initial_Migration in package-manager

The ModelSnapshot is something like it:

The columns, index, pk and fk has applied nameconvention but table names not.

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

namespace Coders.SSO.Migrations
{
    public partial class Initial_Migration : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "abp");

            migrationBuilder.CreateTable(
                name: "AuditLogs",
                schema: "abp",
                columns: table => new
                {
                    id = table.Column<long>(nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    tenant_id = table.Column<int>(nullable: true),
                    user_id = table.Column<long>(nullable: true),
                    service_name = table.Column<string>(maxLength: 256, nullable: true),
                    method_name = table.Column<string>(maxLength: 256, nullable: true),
                    parameters = table.Column<string>(maxLength: 1024, nullable: true),
                    return_value = table.Column<string>(nullable: true),
                    execution_time = table.Column<DateTime>(nullable: false),
                    execution_duration = table.Column<int>(nullable: false),
                    client_ip_address = table.Column<string>(maxLength: 64, nullable: true),
                    client_name = table.Column<string>(maxLength: 128, nullable: true),
                    browser_info = table.Column<string>(maxLength: 512, nullable: true),
                    exception = table.Column<string>(maxLength: 2000, nullable: true),
                    impersonator_user_id = table.Column<long>(nullable: true),
                    impersonator_tenant_id = table.Column<int>(nullable: true),
                    custom_data = table.Column<string>(maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_abp_audit_logs", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "BackgroundJobs",
                schema: "abp",
                columns: table => new
                {
                    id = table.Column<long>(nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    creation_time = table.Column<DateTime>(nullable: false),
                    creator_user_id = table.Column<long>(nullable: true),
                    job_type = table.Column<string>(maxLength: 512, nullable: false),
                    job_args = table.Column<string>(maxLength: 1048576, nullable: false),
                    try_count = table.Column<short>(nullable: false),
                    next_try_time = table.Column<DateTime>(nullable: false),
                    last_try_time = table.Column<DateTime>(nullable: true),
                    is_abandoned = table.Column<bool>(nullable: false),
                    priority = table.Column<byte>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_abp_background_jobs", x => x.id);
                });

          //......
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
miruskycommented, Jul 23, 2022

@princefishthrower I don’t remember what we did in this case, but I’m pretty sure we ended up changing table by table. Because we didn’t have time to create a proper PR with tests and stuff…

My last comment was what we are intended to change in the followin method: https://github.com/aspnetboilerplate/aspnetboilerplate/blob/671d25597251358d2218a80f198edac6f43624c4/src/Abp.ZeroCore.EntityFrameworkCore/Zero/EntityFrameworkCore/AbpZeroDbModelBuilderExtensions.cs#L35

Maybe you could create a new issue with suggested changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.MissingMethodException: Method not found ...
1 Answer. This error occurs when you have different versions of EntityFrameworkCore and NetCore in your project, please be sure to install the ......
Read more >
Customising ASP.NET Core Identity EF Core naming ...
In this post I'll describe how to configure EF Core to use snake_case for database object names instead of Camel Case, so they...
Read more >
Issues with handling composite Tenant / User entity #332
Hi. To extend the existing ABP tenants / users functionality in the system, we had to create corresponding tables / entities which relate...
Read more >
Customizing Application Modules Overriding Services
ExposeServices attribute is needed since ABP can not expose IMyIdentityUserRepository by naming conventions ( MyEfCoreIdentityUserRepository doesn't end ...
Read more >
Articles Tutorials | AspNet Boilerplate
AspNet Boilerplate (ABP) is an open source and well-documented application framework. See the comprehensive tutorials of ABP for technical information.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found