Reverse Engineering from a DB using EF Power Tools

168 Views Asked by At

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; }
2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

You can use:

set.ElementType.Name

to get de Entity name in singular in the Context.tt file.