a query type with the same name already exists

entity-framework-core

Question

The entity type 'MyType' cannot be added to the model because a query type with the same name already exists.

public class MyContext : DbContext
{
    public DbQuery<MyType> MyTypes { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        //Exception is thrown here

        //needed b/c table is not named MyTypes
        modelBuilder.Entity<MyType>()
            .ToTable("MyType");
    }
}
1
4
7/26/2019 2:19:55 AM

Accepted Answer

ZZZ_tmp
6
7/26/2019 2:21:33 AM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow