Cannot Scaffold Access Database after Office365 Upgrade - EFCore + Visual Studio 2019

59 Views Asked by At

I've spent the last three hours trying to resolve this issue to no avail, so I'm coming here for some assistance. I have previously scaffolded a subset of this database, but prior that was prior to being upgraded from 32-bit office 2010 into 64-bit office 365. Full Details below:

Environment

  • Database is an Access Database ( .mdb file )
  • Visual Studio 2019
  • Office 365 - 64 bit ( Access is installed )
  • Windows 10 64-bit
  • EF Packages:
    • EntityFrameworkCore.Jet 3.1.1
    • Microsoft.EntityFrameworkCore 3.1.32
    • Microsoft.EntityFrameworkCore.Design 3.1.32
    • Microsoft.EntityFrameworkCore.Tools 3.1.32

The intial problem:

Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))

After much research, I had narrowed this initial issue down to the system being unable to locate the MS Access DAO dll. Repairing the O365 package did not work to resolve the issue. Upon desperate measures, I investigated that ID in my registry and was found that it was pointing to the old dll location from an Access 2010 32-bit runtime.

The attempted solution

Updating the registry to point to the new dao dll that came with O365 allowed some minor progression:

Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 800700c1 is not a valid Win32 application. (0x800700C1)

So at this stage, I know that I have been able to successfully point to a dll, but since VS2019 is 32-bit application, it fails due to my O365 providing a 64-bit dll. Attempting to compile my app as 64-bit fails completely, as the scaffold tells me it can't work with a 64-bit application (because its running via VS2019, which is 32-bit).

Could not load file or assembly '[MyAssembly], Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.

Attempt 2

Microsoft prevents installation of any other runtimes if you have Office365 Click-To-Run, so I'm unable to install the 32-bit runtime that worked previously. So I simply unpacked the runtime installer, and pointed to the dll directly. Which more progress, but results in the dll failing to initialize.

Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 8007045a A dynamic link library (DLL) initialization routine failed. (0x8007045A).

Moving Forward

At this point, I'm not sure what else to do in order to regain the ability to scaffold this, short of doing the scaffolding on a computer that has not been upgraded to O365 yet.

  • Is there a way to run the scaffolding process as 64-bit ? This would surely resolve the dependency issue, as I have the 64-bit runtime installed. I haven't been able to locate an answer for this, and this is my first instinct here.
  • Obviously I could migrate the database over to SqlServer and do scaffold from there, (which is what I would love to do) but certain actors within the company are currently preventing this migration indefinitely, so for the time being I must deal with the access db.

edit: Kept trying it out, I get this error any time I try in 64-bit.

Microsoft.EntityFrameworkCore.Design.OperationException: Could not load assembly '[MyProject]'. Ensure it is referenced by the startup project '[MyProject]'. ---> System.BadImageFormatException: Could not load file or assembly '[MyProject], Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.

The scaffolding is not 64-bit compatible.

1

There are 1 best solutions below

2
Eugene Astafiev On

The following error message states that your windows registry keys are messed up:

Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 8007045a A dynamic link library (DLL) initialization routine failed. (0x8007045A).

To recover the missing windows registry keys you need to repair/re-install MS Office. This is a widely spread issue when dealing with MS Office applications.