c# - EF反向POCO生成器: Failed to load provider EntityClient

标签 c# visual-studio-2012 sql-server-ce poco entity-framework-6

我正在使用 EntityFramework Reverse POCO Generator在 VS2012 中

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>
  • 安装了 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;
    ...

最佳答案

找到答案了,问题出在ConnectionString

应该如下:

  <connectionStrings>
    <add name="Entities" connectionString="Data Source=C:\StoreContainer.sdf"
      providerName="Microsoft.SqlServerCe.Client.4.0" />
  </connectionStrings>

关于c# - EF反向POCO生成器: Failed to load provider EntityClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24313086/

相关文章:

javascript - 防止从 ASP NET 按钮关闭模式

c# - 在 C# 中将 blob 数据从一个表复制到另一个表

c# - File.Delete 不删除文件

visual-studio-2012 - VS2012 Xaml 设计器 : Where is the resource view?

xaml - 是否可以在 XAML for Visual Studio 2012 中为用户控件创建通用基类

c# - SQL Server CE 3.5 提前切断字符串 (C#)

c# - Bin/Debug 和 Bin/Release 的区别

c# - 在没有安装 Sharepoint 的情况下在 VS 2010 中创建 Sharepoint 目录

visual-studio - 在Visual Studio中使用命令行

c# - 尝试将手动 DataTable 保存到我的 SQL Server CE 表