EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

Error in generating tables

Open apotplant opened this issue 3 years ago • 1 comments

Hi there,

I just purchased a license to do this.

I would like the following tables to be generated but get this error when I run the POCO generator.

SAS_BETA_TRAN1 and SAS_BETA_TRANS both resolve to the same C# name. Filter one of them out.

This seems like a bug to me. Would appreciate some help in this

apotplant avatar Jul 22 '22 05:07 apotplant

Hi @apotplant

This is not a bug. Quite the opposite, it detects where the two or more tables would resolve to the same C# name. For example the following 4 table names would all resolve to the same C# class name, two of them due to pluralisation and two due to CamelCasing:

  • SAS_BETA_TRANS
  • SAS_BETA_TRAN
  • SasBetaTrans
  • SasBetaTran

Using the two table names you provided:

CREATE TABLE SAS_BETA_TRAN1 (id INT NOT NULL, CONSTRAINT pk_a PRIMARY KEY (id));
CREATE TABLE SAS_BETA_TRANS (id INT NOT NULL, CONSTRAINT pk_b PRIMARY KEY (id));

It generated both classes:

// SAS_BETA_TRANS
public class SasBetaTran
{
    public int Id { get; set; } // id (Primary key)
}

// SAS_BETA_TRAN1
public class SasBetaTran1
{
    public int Id { get; set; } // id (Primary key)
}

In your <database>.tt file, what have you got inside of the Settings.TableRename function?

Also, near the bottom of your <database>.tt file, what have you got the pluralisation set to?

Inflector.PluralisationService = new EnglishPluralizationService();

I suspect you have other tables that resolve to the same name and not those two. Try turning pluralisation off for now, see what is output

Inflector.PluralisationService = null;

sjh37 avatar Jul 22 '22 09:07 sjh37