Я пытался заставить ядро EF компилировать базу данных MySQL с использованием сначала БД и Pomelo, но не могу выполнить простые запросы из-за проблемы tinyint (1) bool cast.Попробовал использовать обе эти строки подключения для строительных лесов:
Scaffold-DbContext "Server=ip.address.here;Database=DBNameUsername=UnameHere;Password=PasswordHereTreatTinyAsBoolean=false;" Pomelo.EntityFrameworkCore.MySQL -OutputDir Models -force
Scaffold-DbContext "Server=ip.address.here;Database=DBNameUsername=UnameHere;Password=PasswordHereTreatTinyAsBoolean=true;" Pomelo.EntityFrameworkCore.MySQL -OutputDir Models -force
Если кто-нибудь может указать, что не так, было бы здорово
public static Customer GetCustomerById(int id)
{
try
{
Customer customer = new Customer();
using (Context db = new Context())
{
customer = db.Customer.Single(c => c.CustomerId == id);
}
return customer;
}
catch (Exception err)
{
// always errors on cast conversion failure here
Console.WriteLine("error: " + err);
throw new Exception($"couldn't find the customer with CustomerId: {id}");
}
}
вот модель подмостей:
using System;
using System.Collections.Generic;
namespace Scheduler.Data.Models
{
public partial class Customer
{
public Customer()
{
Appointment = new HashSet<Appointment>();
}
public int CustomerId { get; set; }
public string CustomerName { get; set; }
public int AddressId { get; set; }
public sbyte Active { get; set; }
public DateTime CreateDate { get; set; }
public string CreatedBy { get; set; }
public DateTime LastUpdate { get; set; }
public string LastUpdateBy { get; set; }
public virtual Address Address { get; set; }
public virtual ICollection<Appointment> Appointment { get; set; }
}
}