3
- .NET 4.51
- 實體框架6.x的
我有一個單獨的項目/組件封裝的核心Quartz.NET功能。我想以編程方式配置Quartz.NET以將信息保存到SQL Server。由於這是一個單獨的程序集,所以App.config非常小,我想傳遞一個連接字符串。這裏是完整的App.config:如何使Quartz.NET AdoJobStore與實體框架一起工作?
<?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>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
,這裏是我使用的配置Quartz.NET代碼:
properties["quartz.scheduler.instanceName"] = "My Scheduler";
properties["quartz.scheduler.instanceId"] = "MySchedulerId";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.dataSource.default.connectionString"] = aConnectionString;
properties["quartz.dataSource.default.provider"] = "System.Data.SqlClient";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
爲aConnectionString值是:
測試
"Data Source=.\\SQLEXPRESS;Initial Catalog=xxxxx;Integrated Security=True;MultipleActiveResultSets=True"
生產
server=sql.server.com;User Id=xxxx;password=xxx;Persist Security Info=True;database=xxxx" providerName="System.Data.SqlClient
然而,當我嘗試調用的getScheduler()我收到以下錯誤信息:
Could not Initialize DataSource: default
和內部異常有:
{"There is no metadata information for provider 'System.Data.SqlClient'\r\nParameter name: providerName"}
那麼,什麼是我錯過了嗎?爲了完成這項工作我需要做些什麼改變?
同意。您依賴於使用內置的提供程序......目前只有基於ADO.NET(用於Sql Server)。他們還使用了大量的通用SQL語句來最大限度地減少不同RDBMS之間的需求。但隨時寫一個基於EF的...(如果你有時間的話)...併發布代碼....:O – granadaCoder 2014-08-28 20:26:58
我看過SqlServer-20。需要哪些NuGet包才能在.NET 4.51中工作?我似乎記得那是依賴於.NET 2庫。所以我猜web.config中需要某種形式的「翻譯」才能說使用這些「新」程序集?什麼是必要的陳述? – TheEdge 2014-08-28 23:37:57
應該不需要特別的東西,GAC爲你自動映射,因此提供者清楚地解決了純粹的.NET 4.5.x。 – 2014-08-29 07:09:51