nopSolutions/nopCommerce

After upgrading from v4.40 to v4.50 cannot access data in schemas other than dbo

purplepiranha opened this issue · 2 comments

nopCommerce version: 4.50

Steps to reproduce the problem:

We have several schemas in he database, all mapped via the NopEntityBuilder implementation. e.g.

using FluentMigrator.Builders.Create.Table;
using IntegrationQueues.Core.Domain;
using Nop.Data.Mapping.Builders;
using PurplePiranha.FluentMigrator.Extensions;

namespace IntegrationQueues.Data.Builders
{
    public class IncomingMessageBuilder : NopEntityBuilder<IncomingMessage>
    {
        public override void MapEntity(CreateTableExpressionBuilder table)
        {
            table
                .InSchema(IntegrationQueuesDataDefaults.DatabaseSchemaName)
                .WithColumn(nameof(IncomingMessage.ReceivedCommandId)).AsGuid().NotNullable().Unique()
                .WithColumn(nameof(IncomingMessage.ReceivedCommandName)).AsString(50).NotNullable()
                .WithColumn(nameof(IncomingMessage.ReceivedCommandPayload)).AsStringMax().NotNullable()
                .WithColumn(nameof(IncomingMessage.ReceivedAtUtc)).AsDateTime().NotNullable()
                .WithColumn(nameof(IncomingMessage.AcknowledgeCommandId)).AsGuid().Nullable()
                .WithColumn(nameof(IncomingMessage.AcknowledgedAtUtc)).AsDateTime().Nullable()
                .WithColumn(nameof(IncomingMessage.AcknowledgeIdOrStatus)).AsInt32().Nullable()
                .WithColumn(nameof(IncomingMessage.DebugText)).AsStringMax()
                ;
        }
    }
}

Since upgrading, NopCommerce fails to resolve the schema and throws the following exception:

Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'IncomingMessage'.

I have tried recreating the table in the default dbo schema and it is accessible.

Note: This is using MsSqlDataProvider

I've added a PR for this. Let me know if there is anything that I've missed or should be done differently.

Closed #6139