question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetAppliedMigrations() throws OleDBException

See original GitHub issue

I am currently playing around with this provider and recently updgraded from the 2.2.X release to the recently merged 3.1. Until the merge I could use “MyContext.Database.GetAppliedMigrations()” successfully. Now the call raises :

System.Data.OleDb.OleDbException: 'Invalid SQL statement; expected ‘DELETE’, ‘INSERT’, ‘PROCEDURE’, ‘SELECT’, or ‘UPDATE’.

I am using the following configuration for my context:

JetConfiguration.ShowSqlStatements = true;
JetConfiguration.DUAL = JetConfiguration.DUALForMdb;
JetConfiguration.UseConnectionPooling = false;
JetConfiguration.DefaultDataAccessProviderType = DataAccessProviderType.OleDb;

 var lconnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;User ID=Admin; Data Source=\"<somevalidpath>\";Mode=Share Deny None;Jet OLEDB:Database Password=\"<somevalidpassword>\";";
optionsBuilder.UseJet(lconnectionString, OleDBFactory.Instance);

I tried some variations of this configuration:

  • With and without OleDBFactory.Instance
  • With and without JetConfiguration.DefaultDataAccessProviderType = DataAccessProviderType.OleDb;

Have I missed some obvious change in the framework or is this an bug?

UPDATE: I forgot to mention that I am using MDB files.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xoniuqecommented, Nov 25, 2020

My Code:

using(var context = MyContext()) 
{
    context.Database.GetAppliedMigrations();
}

The full stacktrace: ( I obfuscated some project names but the rest is unchanged)

System.Data.OleDb.OleDbException (0x80040E14): Unzulässige SQL-Anweisung; 'DELETE', 'INSERT', 'SELECT' oder 'UPDATE' erwartet.
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteScalar()
   at System.Data.Jet.JetCommand.ExecuteScalarCore()
   at System.Data.Jet.JetCommand.ExecuteScalar()
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalar(RelationalCommandParameterObject parameterObject)
   at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
   at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.GetAppliedMigrations()
   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.GetAppliedMigrations(DatabaseFacade databaseFacade)
   at Project.UI.ViewModel.DatabaseViewModel.Migrate() in D:\Prototype\Project\Project.UI\ViewModel\DatabaseViewModel.cs:line 41
   at Project.UI.ViewModel.DatabaseViewModel.<get_UpdateCommand>b__13_0() in D:\Prototype\Project\Project.UI\ViewModel\DatabaseViewModel.cs:line 81
   at Company.UI.Commands.DelegateCommand.<>c__DisplayClass0_0.<.ctor>b__0(Object _) in D:\Prototype\Project\DotNetLib\Company.UI\Commands\DelegateCommand.cs:line 30
   at Company.UI.Commands.DelegateCommand`1.Execute(Object pParameter) in D:\Prototype\Project\DotNetLib\Company.UI\Commands\DelegateCommand.cs:line 138
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at Prototype.App.Main()
0reactions
lauxjpncommented, Nov 26, 2020

If this is not related I can also open another issue.

@xoniuqe I moved it to #71.

Read more comments on GitHub >

github_iconTop Results From Across the Web

oledb - C# oledbexception
I keep getting a exception of type OleDbException . ... The line with ** is what throws the exception. ... ExecuteReader() line?
Read more >
OleDbException Class (System.Data.OleDb)
The exception that is thrown when the underlying provider returns a warning or error for an OLE DB data source. This class cannot...
Read more >
RelationalDatabaseFacadeExten...
Gets all migrations that have been applied to the target database.
Read more >
Version 3.1.8 GetAppliedMigrations & ...
System.NullReferenceException: 'Object reference not set to an instance of an object.' EF Core version: 3.1.8 Database provider: Devart.Data.
Read more >
Remove migration does not remove unapplied ...
The following error is thrown when attempting to remove an unapplied migration: ... GetAppliedMigrations() call will check the history table in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found