2014-10-12 19 views
18

Tôi nhận được lỗi này với gói Nuget cho SQLite 1.0.94.1. Tôi đã chơi đùa với các phần app.config khác nhau, được hỗ trợ bởi các câu hỏi tương tự về các phiên bản trước của gói này, nhưng tôi không thể làm cho nó hoạt động. Dưới đây là app.config khi tôi tìm thấy nó sau khi cài đặt gói Nuget. Tôi đã xóa app.config trước khi cài đặt nó. Tôi chỉ thêm các kết nối sau đó.Không thể xác định tên nhà cung cấp cho nhà máy cung cấp loại 'System.Data.SQLite.SQLiteFactory'. với phiên bản gói Nuget 1.0.94.1

Vì vậy, đâu là vấn đề ??

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <!--Added by me, the rest of the app.config was constructed by installing the SQLite package --> 
    <connectionStrings> 
    <add name="PrivateMessengerContext" connectionString="DataSource=|DataDirectory|\PrivateMessengerDb.db" providerName="System.Data.SQLite.EF6"/> 
    <add name="PasswordContext" connectionString="DataSource=|DataDirectory|\PasswordDb.db" providerName="System.Data.SQLite.EF6"/> 
    </connectionStrings> 
    <system.data> 
    <!-- 
     NOTE: The extra "remove" element below is to prevent the design-time 
      support components within EF6 from selecting the legacy ADO.NET 
      provider for SQLite (i.e. the one without any EF6 support). It 
      appears to only consider the first ADO.NET provider in the list 
      within the resulting "app.config" or "web.config" file. 
    --> 
    <DbProviderFactories> 
     <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> 
     <remove invariant="System.Data.SQLite" /> 
     <remove invariant="System.Data.SQLite.EF6" /> 
     <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> 
    </DbProviderFactories> 
    </system.data> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
     <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> 
    </providers> 
    </entityFramework> 
</configuration> 
+1

App.config đó có noy trông đúng. Xin vui lòng xóa và chỉ cài đặt gói sqlite.ef6 - nhưng expdct nó được run rẩy, đề nghị Yiu báo cáo bất kỳ vấn đề tại system.data.sqlite.org – ErikEJ

+1

@ErikEJ tôi gỡ bỏ cài đặt các gói và cài đặt lại chỉ gói EF6. Ít phụ thuộc hơn đã được cài đặt ngay bây giờ, nhưng app.config resuling là giống hệt nhau và lỗi vẫn còn. Gói này có hơn 4.000 lượt tải xuống, do đó, phải có trình hướng dẫn có sẵn để hoạt động. – Dabblernl

+1

Khi nào bạn gặp lỗi? – ErikEJ

Trả lời

21

Thêm một nhà cung cấp

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />

di chuyển

<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />

dưới

<remove invariant="System.Data.SQLite" />

và đổi tên nhà cung cấp thành providerName="System.Data.SQLite trong chuỗi kết nối của bạn.

EDIT: Xem thêm http://system.data.sqlite.org/index.html/tktview/2be4298631c01be99475

+2

Tôi có cùng một vấn đề sự khác biệt là tôi sử dụng entityframework.6.1.3.nupkg, vì vậy khi tôi thực hiện lời khuyên của bạn ném ngoại lệ này ADO.Nhà cung cấp NET với tên bất biến 'System.Data.SQLite' không được đăng ký trong máy hoặc tệp cấu hình ứng dụng hoặc không thể tải được. – Cyberguille

7

gì làm việc cho tôi là để làm theo những nhận xét trên 2015/04/29 08:33:33 trong SQLite ticket:

Nếu bạn chuyển sang dự án nhắm mục tiêu nền tảng từ 4.5.1 đến 4 và cài đặt lại NuGet gói bạn sẽ có nó tất cả làm việc (thậm chí nếu sau đó bạn trở lại cho 4.5.1)"

Might h ave một hiệu ứng tương tự trên cấu hình để trả lời của Mihail, không chắc chắn.

+2

Đã giải quyết một cách kỳ diệu của tôi .. Chỉ cần lưu ý (như đã nói trong câu trả lời); phiên bản nền tảng của tôi là 4.5. Với việc quay trở lại nền tảng phiên bản 4, cài đặt lại SQLite và sau đó quay trở lại 4.5 để nó hoạt động. – myuce

+0

Sau đó tôi đã có một vấn đề khác, bởi vì Sqllite.CodeFirst yêu cầu một EntityFramework gần đây. Tôi đã phải cập nhật EntityFramework theo cách thủ công từ 6.1.0 đến 6.1.3 (bấm vào số phiên bản). Bây giờ tôi đã làm xong, trên .NET v4.0. – Jarekczek

Các vấn đề liên quan