Name conflict: when table name is the same name as the project namespace

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
RobertK
Posts: 56
Joined: Thu 02 Mar 2017 05:44

Name conflict: when table name is the same name as the project namespace

Post by RobertK » Tue 14 Nov 2017 00:35

Example
Project Name: Company.Account.API
Context Namespace: Company.Account.API.Data
Default Namespace: Company.Account.API.DataModels

Table Name: Account


Error message in "ApplicationDbContext.cs" "Account" is a namespace but used like a type

Code: Select all

namespace Company.Account.API.Data
{
        public virtual DbSet<Account> Accounts { get; set; }
}

Workaround: You must manually edit and update each file to fix the issue.

Change name from "Account" to "Account.API.DataModels.Account"
Example
1)
From

Code: Select all

public virtual DbSet<Account> Accounts { get; set; }
To

Code: Select all

public virtual DbSet<Account.API.DataModels.Account> Accounts { get; set; }

2)
From

Code: Select all

        #region Account Navigation properties
            modelBuilder.Entity<Account>().HasOne(x => x.AccountType).WithMany(op => op.Accounts).IsRequired(true).HasForeignKey(@"AccountTypeId");
        #endregion
To

Code: Select all

        #region Account Navigation properties
            modelBuilder.Entity<Account.API.DataModels.Account>().HasOne(x => x.AccountType).WithMany(op => op.Accounts).IsRequired(true).HasForeignKey(@"AccountTypeId");
        #endregion

RobertK
Posts: 56
Joined: Thu 02 Mar 2017 05:44

Re: Name conflict: when table name is the same name as the project namespace

Post by RobertK » Thu 16 Nov 2017 10:17

Anyone know how to fix this issue without manually having to edit the generated code?

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Name conflict: when table name is the same name as the project namespace

Post by Shalex » Thu 16 Nov 2017 20:29

We have reproduced the issue and are investigating it.

RobertK
Posts: 56
Joined: Thu 02 Mar 2017 05:44

Re: Name conflict: when table name is the same name as the project namespace

Post by RobertK » Mon 20 Nov 2017 03:42

Shalex wrote:We have reproduced the issue and are investigating it.
Thanks!

A simple fix is to allow adding an option to generate full names either for all models or just conflict names? (check is the project name the same as the model name? if true generate full name)

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Name conflict: when table name is the same name as the project namespace

Post by Shalex » Mon 20 Nov 2017 10:49

The issue is fixed. Look forward to the next public build of Entity Developer.

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Re: Name conflict: when table name is the same name as the project namespace

Post by Shalex » Fri 24 Nov 2017 08:57

The new (6.2.384) build of Entity Developer is available for download.

Post Reply