0
我使用了「實體數據模型嚮導」不能使用SQLite實體框架作爲數據源的DataGridView
這工作得很好,我一直在編程aginst它一個簡單的SQLite數據庫建立了一個實體框架模型一會兒。
不過,我只是想用這個SQLite的實體框架模型作爲一個DataGridView一個數據源,並不能看到它作爲一個數據源。一切都表明這應該是可能的。從同一個數據庫創建一個DataSet可以工作,DataGridView可以將其用作數據源。
我寧願使用實體框架,但不明白爲什麼它沒有看到它作爲一個有效的數據源。
請幫忙!
如這裏要求的是app.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections></configSections>
<system.data>
<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" />
</DbProviderFactories>
</system.data>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog" />
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" />
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<connectionStrings>
<add name="simpleEntities" connectionString="metadata=res://*/GEM.Classes.test1.csdl|res://*/GEM.Classes.test1.ssdl|res://*/GEM.Classes.test1.msl;provider=System.Data.SQLite;provider connection string="data source=E:\simple.db3"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
作爲一個測試,我用了一個很簡單的數據庫:
CREATE TABLE SETTINGS (
KEY VARCHAR(50) PRIMARY KEY NOT NULL ,
VALUE VARCHAR(255) NULL DEFAULT NULL);
它可以是你沒有相應的條目添加到您的web.config文件? – Pawel
PLease顯示相關的代碼。 DGV可以接受DbSet(或ObjectSet)作爲數據源,所以其他內容必須是錯誤的。 –
我已經按要求添加了app.config文件和sql。 –