0

这里是我的解决方案架构:添加在Visual Studio扩展实体框架配置

  • VM(IIb类)=>引用的SQLite。
  • 应用程序(WPF桌面应用程序)=>引用虚拟机。
  • VSIX(Visual Studio扩展)=>引用VM。

我已将VM项目的app.config的EF提供程序相关内容复制到桌面应用程序和VSIX项目。桌面应用程序工作正常,而VSIX项目抛出以下异常:

未找到具有不变名称“System.Data.SQLite.EF6”的ADO.NET提供程序的实体框架提供程序。确保提供程序在应用程序配置文件的'entityFramework'部分中注册。

在扩展项目的情况下,我需要做些什么吗?

回答

0

添加在下面的类中的最后一行固定对我来说:

public class SQLiteConfiguration : DbConfiguration 
{ 
    public SQLiteConfiguration() 
    { 
    SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance); 
    SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance); 
    SetProviderServices("System.Data.SQLite", (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices))); 
    SetProviderServices("System.Data.SQLite.EF6", (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices))); 
    } 
} 

不知道为什么,这个异常只被扔在VSIX项目,而不是桌面应用程序。

可能帮助某人在路上。