EF反向POCO生成器:无法加载提供者EntityClient

K. *_*R. 6 c# poco sql-server-ce visual-studio-2012 entity-framework-6

我在VS2012中使用 EntityFramework Reverse POCO Generator

VS2012 ...

这是我的连接字符串:

<connectionStrings>
    <add name="Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;data source=C:\SomeDatabase.sdf&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
Run Code Online (Sandbox Code Playgroud)
  • 安装了nuget EntityFramework.SqlServerCompact
  • 安装了Visual Studio的Entity Framework 6.1.0工具
  • 将System.Data.Entity添加到我的引用中

更新了.tt文件以指向我的connectionString,当我保存时,我收到此错误(警告)::

警告1运行转换:无法加载提供程序"System.Data.EntityClient" - 无法找到请求的.Net Framework数据提供程序.它可能没有安装.

所以它没有生成任何代码.有任何想法吗?

这是Database.tt文件的片段:

<#@ include file="EF.Reverse.POCO.Core.ttinclude" #>
<#
    // v2.5.0
    // Please make changes to the settings below.
    // All you have to do is save this file, and the output file(s) is/are generated. Compiling does not regenerate the file(s).

    // Misc settings **********************************************************************************************************************
    // Namespace = ""; // Override the default namespace here
    DbContextName = "MyContext";
    ConnectionStringName = "Entities";  // Searches for this connection string in config files listed below
    ConfigurationClassName = "Configuration"; // Configuration, Mapping, Map, etc. This is appended to the Poco class name to configure the mappings.
    ConfigFilenameSearchOrder = new[] { "app.config", "web.config", "app.config.transform", "web.config.transform" }; // Add more here if required. The config files are searched for in the local project first, then the whole solution second.
    MakeClassesPartial = true;
    ...
Run Code Online (Sandbox Code Playgroud)

K. *_*R. 5

找到了答案,问题出在ConnectionString中

应该如下:

  <connectionStrings>
    <add name="Entities" connectionString="Data Source=C:\StoreContainer.sdf"
      providerName="Microsoft.SqlServerCe.Client.4.0" />
  </connectionStrings>
Run Code Online (Sandbox Code Playgroud)