Hello,

I am struggling to install a new plugin with two tables that have a relational dependence.

When I install it, it tells me with an error "There is already an object named 'A' in the database.".

Here's the simplified code:

    public class A : BaseEntity
    {
        public virtual ICollection<B> BList { get; set; }
    }


    public class B : BaseEntity
    {
        public virtual int AId { get; set; }
        public virtual A A { get; set; }
    }



public class AMap: NopEntityTypeConfiguration<AMap>
    {
        public AMap()
        {
            ToTable("ARecord");
            HasKey(a => a.Id);
        }
    }



    public class BMap : NopEntityTypeConfiguration<BMap>
    {
        public BMap()
        {
            ToTable("BRecord");
            HasKey(b => b.Id);
            HasRequired(b => b.A)
                .WithMany(a => a.BList)
                .HasForeignKey(b => b.BId)
                .WillCascadeOnDelete();
        }
    }


In my CorePlugin.cs, I am calling B.install() only, because I realised that I don't need to call A.install() since they have a relation, EF creates both of them in one call.

With the debugger I see this:

create table [dbo].[BRecord] (
    [Id] [int] not null identity,
    [AId] [int] not null,
    primary key ([Id])
);
create table [dbo].[ARecords] (
    [Id] [int] not null identity,
    primary key ([Id])
);
alter table [dbo].[BRecord] add constraint [BRecord_ARecord] foreign key ([AId]) references [dbo].[ARecords]([Id]) on delete cascade;


The two tables are created in the database after clicking the install button.
EF creates a "ARecords" table even if I write ToTable("ARecord");

Even if it seems all right, I get "There is already an object named 'A' in the database."

Thank you very much for your help,

Regards.