带有 Sharepoint 2013 的实体框架 6 [英] Entity Framework 6 with Sharepoint 2013

查看:38
本文介绍了带有 Sharepoint 2013 的实体框架 6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试让 SharePoint 2013 应用程序页面或 Web 部件与 Entity Framework 6(确切地说是 6.0.1 - 在撰写本文时默认使用 NuGet 安装到 Visual Studio 2012 中的版本)一起工作,但没有成功.

I tried without success to get a SharePoint 2013 application page or web part to work with Entity Framework 6 (6.0.1 to be exact - the version installed into Visual Studio 2012 by default using NuGet at time of writing).

出于测试目的,我的代码非常简单,只是从一个表中读取数据.

My code was very simple for test purposes, just reading data from one table.

我可以很好地安装软件包,创建模型,查看它们是否已正确配置等,没问题 - 但每当我尝试加载页面时,我都会收到错误:

I could install the package just fine, create models, see that the they were properly configured etc, no problem - but whenever I tried to load the page I got the error:

事件代码:3008异常类型:ConfigurationErrorsException异常消息:为 entityFramework 创建配置节处理程序时出错:无法加载文件或程序集EntityFramework"或其依赖项之一.该系统找不到指定的文件.(C:inetpubwwwrootwssVirtualDirectories[站点名称]web.config 第 36 行)

Event code: 3008 Exception type: ConfigurationErrorsException Exception message: An error occurred creating the configuration section handler for entityFramework: Could not load file or assembly 'EntityFramework' or one of its dependencies. The system cannot find the file specified. (C:inetpubwwwrootwssVirtualDirectories[sitename]web.config line 36)

我将 VS 中的 App.Config 文件(由 EF 安装创建)中的所有配置设置逐字复制到 web.config 中.

I copied all of the config settings from the App.Config file in VS (created by the EF install), into the web.config, verbatim.

我尝试了可以​​在互联网上找到的所有建议修复(例如,将 EF 程序集引用更改为特定版本 = false",将配置文件中的版本引用更改为特定版本......各种)但没有任何效果.

I tried every suggested fix I could find on the interweb (e.g. changing the EF assembly ref to "Specific version = false", changing version refs in the config file to the specific version... all sorts) but nothing worked.

我使用相同的设置创建了一个控制台应用程序,它运行良好,所以我知道这不是特定于服务器的问题 - 看起来像是与 SP2013 的兼容性问题,有人有什么想法吗?

I created a console app using the same settings and it worked fine, so I know it's not a server-specific issue - looks like a compatibility issue with SP2013, anyone have any ideas?

我使用 NuGet 控制台安装了 EF 5,最后让它与它一起工作......但我很好奇为什么 EF 6 拒绝玩球.

I installed EF 5 using the NuGet console, and finally got it working with that... but I'm very curious as to why EF 6 refused to play ball.

谢谢普里奥

推荐答案

您需要将实体框架程序集(EntityFramework.dll、EntityFramework.SqlServer.dll)部署为 SharePoint 解决方案包的一部分.您可以在包中引用外部 dll.

You need to deploy the Entity Framework assemblies (EntityFramework.dll, EntityFramework.SqlServer.dll) as part of your SharePoint solution package. You can reference external dlls in the package.

这篇关于带有 Sharepoint 2013 的实体框架 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆