Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find plural form of table

For some reason code-first EF7 (vNext) will not use/find the plural form of my table. I have tried adding the table attribute to the model but it does not solve the problem.

[Table("Units")]
public class Unit

If I name the table Unit then no problem. If I name the table Units then it's not found.

What am I doing wrong or missing?

Thank you.

like image 801
user390480 Avatar asked Mar 18 '23 02:03

user390480


2 Answers

This is how I resolved:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    modelBuilder.Entity<Unit>().ToTable("Units");
}
like image 121
user390480 Avatar answered Mar 23 '23 16:03

user390480


For Entity Framework 7 beta1, I solved this issue by this way:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);
    modelBuilder.Entity<Unit>().ForRelational(rb =>
    {
        rb.Table("Units");
    });
}
like image 43
Ricky Avatar answered Mar 23 '23 18:03

Ricky