Search code examples
entity-frameworkasp.net-mvc-4ef-power-tools

Reverse Engineering from a DB using EF Power Tools


I'm using EF Power Tools to Reverse Engineering from a DB.

while in the context it properly writes

//TABLE NAME: USERS    
public DbSet<Users> Users { get; set; }

in the entity class it writes

public partial class User

Where the system is changing the name of the table from 'Users' (correct) to 'User' (not correct)?

Please note that i modified the Context.tt

<#
    foreach (var set in efHost.EntityContainer.BaseEntitySets.OfType<EntitySet>())
    {
#>
        public DbSet<<#= set.Name #>> <#= set.Name #> { get; set; }
<#
    }
#>

because in my context i want to have

 public DbSet<TABLE_NAME> TABLE_NAME { get; set; }

Solution

  • It should be after the line (or not far)

    namespace <#= code.EscapeNamespace(efHost.Namespace) #>
    {
    

    in Entity.tt

    You should find a line public class <#= efHost.EntityType.Name #> which you'll have to change.

    By the way, I think it's a bad idea, as this way of naming is a kind of convention for EF :

    DbSet is pluralized, class is in the singular.