Использую EF Core и мне нужно получить запись по имени.
Запрос
public async Task<T> GetAnimalByNameAsync(string animalName)
{
return await _dataContext.Set<T>()
.Include(x => x.Breed)
.FirstOrDefaultAsync(x => x.Name.Equals(animalName));
}
Контекст БД
public DbSet<Breed> AnimalBreeds { get; set; }
public DbSet<AnimalEntity> Animals { get; set; }
public DbSet<Food> Foods { get; set; }
public DbSet<Cat> Cats { get; set; }
public DbSet<Dog> Dogs { get; set; }
public DbSet<Feeding> Feedings { get; set; }
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.UseCollation("Latin1_General_CP1_CI_AS");
modelBuilder.UseCollation("Cyrillic_General_CI_AS");
modelBuilder.Entity<Breed>().Property(e => e.Type)
.HasConversion(
x => x.ToString(),
v => (AnimalType)Enum.Parse(typeof(AnimalType), v));
modelBuilder.Entity<Cat>().Property(e => e.Type)
.HasConversion(
x => x.ToString(),
v => (AnimalType)Enum.Parse(typeof(AnimalType), v));
modelBuilder.Entity<Dog>().Property(e => e.Type)
.HasConversion(
x => x.ToString(),
v => (AnimalType)Enum.Parse(typeof(AnimalType), v));
modelBuilder.Entity<Food>().Property(e => e.Type)
.HasConversion(
x => x.ToString(),
v => (AnimalType)Enum.Parse(typeof(AnimalType), v));
}
При создании миграции получаю исключение
Базу данных использую Postgresql