Skip to content

GetAppliedMigrations() throws OleDBException #69

Closed

Description

@xoniuqe

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.

Activity

  1. self-assigned this
    on Nov 25, 2020
  2. lauxjpn commented on Nov 25, 2020

    @lauxjpn
    Member

    What does the SQL statement with the syntax error exactly look like?
    What migration operation of your migration code is failing?

  3. xoniuqe commented on Nov 25, 2020

    @xoniuqe
    ContributorAuthor

    I am not even running a migration. The error came out of the System.Data.Jet\JetCommand.
    The SQL statement was "SHOW TABLES WHERE NAME='__EFMigrationsHistory'". As I understand it this is just the code that checks if the history table exists.

  4. lauxjpn commented on Nov 25, 2020

    @lauxjpn
    Member

    I am not even running a migration. The error came out of the System.Data.Jet\JetCommand.

    That is definitely odd. If you are not running migrations, what code are you running when the exception is thrown?
    Also, please provide us with the full stack trace of the OleDbException.

  5. xoniuqe commented on Nov 25, 2020

    @xoniuqe
    ContributorAuthor

    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()
    
  6. lauxjpn commented on Nov 25, 2020

    @lauxjpn
    Member

    Okay, so you do call context.Database.GetAppliedMigrations(); after all.
    Seems to be just the Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists() call.
    I'll take a look at it.

  7. xoniuqe commented on Nov 25, 2020

    @xoniuqe
    ContributorAuthor

    Yes I call the function, then I have missunderstood you.

  8. added this to the 3.1.0-alpha.1 milestone on Nov 25, 2020
  9. lauxjpn commented on Nov 25, 2020

    @lauxjpn
    Member

    @ChrisJollyAU Yeah, I am already updating the whole file. It is still using the old schema syntax.

  10. ChrisJollyAU commented on Nov 25, 2020

    @ChrisJollyAU
    Member

    Outside of the tests it looks like it's the only place that uses it

  11. lauxjpn commented on Nov 25, 2020

    @lauxjpn
    Member

    I'll have to do a couple more checks about the IF EXISTS() THEN and IF NOT EXISTS() THEN syntax, manually test some migrations and update the tests.

  12. xoniuqe commented on Nov 26, 2020

    @xoniuqe
    ContributorAuthor

    I pulled your fix repo and it seems to resolve the issue I statet here. However something else breaks now: I get en exception from the class DaoSchema constructor line 52
    _database = _workspace.OpenDatabase(dataSource, /* Exclusive */ false, /* ReadOnly */ true, string.Empty);:

    The repro is exactly same as in the first post.

    System.Reflection.TargetInvocationException
      HResult=0x80131604
      Message=Ein Aufrufziel hat einen Ausnahmefehler verursacht.
      Source=mscorlib
      StackTrace:
       at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
       at System.Data.Jet.ComObject.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\ComObject.cs:line 113
       at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
       at System.Data.Jet.DaoSchema..ctor(JetConnection connection) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\DaoSchema.cs:line 63
       at System.Data.Jet.DaoSchema..ctor(JetConnection connection, Boolean naturalOnly) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\DaoSchema.cs:line 17
       at System.Data.Jet.PreciseSchema..ctor(JetConnection connection) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\PreciseSchema.cs:line 13
       at System.Data.Jet.SchemaProvider.CreateInstance(SchemaProviderType type, JetConnection connection) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\SchemaProvider.cs:line 15
       at System.Data.Jet.JetStoreSchemaDefinition.JetInformationSchema.GetTables(JetConnection connection) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\JetStoreSchemaDefinition\JetInformationSchema.cs:line 109
       at System.Data.Jet.JetStoreSchemaDefinition.JetInformationSchema.GetDbDataReaderFromSimpleStatement(JetCommand command) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\JetStoreSchemaDefinition\JetInformationSchema.cs:line 75
       at System.Data.Jet.JetStoreSchemaDefinition.JetInformationSchema.TryGetDataReaderFromInformationSchemaCommand(JetCommand command, DbDataReader& dataReader) in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\JetStoreSchemaDefinition\JetInformationSchema.cs:line 18
       at System.Data.Jet.JetCommand.ExecuteScalarCore() in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\JetCommand.cs:line 323
       at System.Data.Jet.JetCommand.ExecuteScalar() in D:\EntityFrameworkCore.Jet\src\System.Data.Jet\JetCommand.cs:line 304
       at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalar(RelationalCommandParameterObject parameterObject)
    
    Inner Exception 1:
    COMException: Not a valid password.
    
    

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

  13. lauxjpn commented on Nov 26, 2020

    @lauxjpn
    Member

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

    @xoniuqe I moved it to #71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions