2013-06-03 116 views
1

我正在從EF4到EF5的Silverlight/WCF RIA服務項目。目標是.NET4.5如何判斷是否使用EF5

這是一個尖峯 - 我正在使用數據庫優先方法。即創建EDMX,然後使用域服務類嚮導

enter image description here

所以看起來不錯,只要有

  • 的EntityFramework(5.0.0.0)
  • Microsoft.ServiceModel.DomainServices.EntityFramework( 4.0.0.0)DbDomainService在這裏
  • System.Data.Entity(4.0.0.0)

而非的舊方式:

  • 的EntityFramework(5.0.0.0)
  • System.Data.Entity的(4.0.0.0)
  • System.ServiceModel.DomainServices.EntityFramework(4.0.0.0)LinqToEntitiesDomainService在這裏

enter image description here

則已經把一個簡單的用戶界面上訪問2臺數據庫和它的工作 enter image description here

問題:這是web.config中不是我期望:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="system.serviceModel"> 
     <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" /> 
    </sectionGroup> 
    </configSections> 
    <system.web> 
    <httpModules> 
     <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </httpModules> 
    <compilation debug="true" targetFramework="4.5"> 
     <assemblies> 
     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     </assemblies> 
    </compilation> 
    <!-- profile stuff commented out--> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </modules> 
    </system.webServer> 
    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <connectionStrings> 
    <add name="DefaultConnection" connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=aspnet-BusinessApplication5.Web-20130603151851;Integrated Security=True" providerName="System.Data.SqlClient" /> 
    <add name="TestDBEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=TestDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
</configuration> 

我期待要投入:

<configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 

    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 

得到了配置的這些位從以下。也許他們都是codefirst特定的。 https://github.com/jeffhandley/riabooks

http://jeffhandley.com/archive/2012/12/10/RIA-Services-NuGet-Package-Updates-ndash-Including-Support-for-EntityFramework.aspx

http://mcasamento.blogspot.co.uk/2012/10/entity-framework-5-code-first-and-wcf.html

回答

2

的RIA服務編譯DLL對EF 4,不EF5,所以結合重定向來使一切工作。如果/當RIA Services是開放源代碼的時候,將會有一個RiaServices.EntityFramework的新版本,它將會針對EF 5和EF 6編譯。開源的好處之一是能夠根據需要發佈儘可能多的NuGet包支持所有組合。

+0

感謝科林 - 在這裏寫下了我的筆記http://www.programgood.net/2013/06/04/EF5AndRIAServicesHowToReallyDoIt.aspx –