Jorge
Jorge

Reputation: 18257

Can't avoid pluralization with Entity Framework 4.1

I created a class called Usuario like this

public class Usuario
{
    #region Atributos
    private int _intID = 0;
    private Perfil _Perfil_FK = null;
    private String _strNombre = "";
    private String _strPassword = "";
    #endregion

    #region Propiedades
    public int ID
    {
        get { return _intID; }
        set { _intID = value; }
    }
    public virtual Perfil Perfil_FK
    {
        get { return _Perfil_FK; }
        set { _Perfil_FK = value; }
    }
    public String Nombre
    {
        get { return _strNombre; }
        set { _strNombre = value; }
    }
    public String Password
    {
        get { return _strPassword; }
        set { _strPassword = value; }
    }
    #endregion
}

And for my context I defined this property to avoid the pluralization

protected override void OnModelCreating(System.Data.Entity.ModelConfiguration.ModelBuilder modelBuilder)
{
    modelBuilder.Conventions.Remove<PluralizingEntitySetNameConvention>();
    base.OnModelCreating(modelBuilder);
} 

I tried to find a table called Usuarios instead Usuario why am I doing wrong??. Do I need another configuration??

Upvotes: 0

Views: 253

Answers (1)

Morten Mertner
Morten Mertner

Reputation: 9474

Try using this instead:

modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

That works for me here (albeit with EF 4.0).

Upvotes: 1

Related Questions