При загрузки формы выдает ошибку связанную с Ядром СУБД
Ошибка: Ядру СУБД Microsoft Access не удается найти входную таблицу или запрос "Questions". Убедитесь, что объект существует, а его имя указано правильно.
Используется СУБД Access
public partial class TestLesson : Window
{
private readonly MobileContext _context =
new MobileContext();
public TestLesson()
{
InitializeComponent();
}
private int time;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
_context.Database.EnsureCreated();
_context.Questions.Load(); // Ядро Субд ошибка
}
public void GoToTimer()
{
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
void timer_Tick(object sender, EventArgs e)
{
time++;
textBlockTimer.Text = ($"{time / 60}:{time % 60}");
if (time == Convert.ToInt32(_context.Questions.Local.ToObservableCollection().Select(t => t.time).FirstOrDefault()))
{
MessageBox.Show("OK");
}
}
}
}
Класс связи с бд
public class MobileContext : DbContext
{
public DbSet<Action> ActionsAll { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<ButtonGen> ButtonGens { get; set; }
public DbSet<Question> Questions { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseJet(Properties.Settings.Default.BDConnectionString);
}
}
Класс объекта
[Table(Name = "Question")]
public class Question
{
[Column(Name = "id", IsPrimaryKey = true, IsDbGenerated = true)]
public int id { get; set; }
[Column(Name = "Вопрос")]
public string question { get; set; }
[Column(Name = "Ответ")]
public string answerOne { get; set; }
[Column(Name = "Ответ2")]
public string answerTwo { get; set; }
[Column(Name = "Ответ3")]
public string answerThree { get; set; }
[Column(Name = "Ответ4")]
public string answerFour { get; set; }
[Column(Name = "ОтветПрав")]
public string answerTrue { get; set; }
[Column(Name = "TestId")]
public int idTest { get; set; }
[Column(Name = "Image")]
public string time { get; set; }
}
