dotnet / ef6

This is the codebase for Entity Framework 6 (previously maintained at https://entityframework.codeplex.com). Entity Framework Core is maintained at https://github.com/dotnet/efcore.
https://docs.microsoft.com/ef/ef6
MIT License
1.42k stars 543 forks source link

PowerTool's Generate View with Sqlite fails with Exception #523

Closed Euphoric closed 2 years ago

Euphoric commented 6 years ago

I'm using Entity Framework 6 with Sqlite provider. Everything works fine, but when I try to use Power Tools to Generate Views to optimize first-time query, I'm getting exceptions.

Attached is sample project. SqliteEfGenerateView.zip

I followed https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider to create a project with Database-First edmx with Sqlite. I made sure assemblies are in GAC and configuration in machine.config. I created trivial DB with single table and two columns. When I run the application, everything is fine. Designer for edmx file also works properly.

But when I right edmx file, and use Generate Views, following exception is written into output:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: 
Model.edmx(7,6) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SQLite.EF6'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.ThrowOnNonWarningErrors()
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, Boolean throwOnError, IDbDependencyResolver resolver)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, IDbDependencyResolver resolver, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerInvariantName, String& providerManifestToken, Memoizer`2& cachedCTypeFunction)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Microsoft.DbContextPackage.Utilities.EdmxUtility.GetMappingCollectionEF6(Assembly ef6Assembly, String& containerName)
   at Microsoft.DbContextPackage.Handlers.OptimizeContextHandler.OptimizeEdmx(String inputPath)

When I do the same on Context.cs file, I'm getting different error : sqlite factory error

I managed to replicate this both on my work PC and my home PC. Both with same configuration.

Attempts at fixing it

I spent whole day messing with app.config, adding and removing lines around providers. Nothing helps. It seems the app.config is not even read when Generate Views is used.

Further technical details

EF version: 6.2.0 (same with 6.0.0) Database Provider: Sqlite 1.0.108 (but same with 1.0.94) Operating system: Windows 10 IDE: Visual Studio 2017 15.6.1 and 15.6.6

ErikEJ commented 6 years ago

Make sure the same version is installed in GAC, and regsitered in machine.config

Euphoric commented 6 years ago

@ErikEJ System.Data.Sqlite.Core is missing, should I register it?. Rest are on 1.0.108 sqlite gacutil

And machine.config is same as in the tutorial. machine config

ErikEJ commented 6 years ago

Looks OK...

Euphoric commented 6 years ago

Is anyone looking at this problem? Is this problem reproducible? Is there anything else I could do to help debug this issue?

ajcvickers commented 2 years ago

This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.