EntityDataSource和Entity Framework 6 [英] EntityDataSource and Entity Framework 6
问题描述
我学习ASP.NET。我来到EntityDataSorce控制。我使用EF6。我已阅读,这种控制和EF6有一些问题,矛盾,但与上次更新EntityDataSource这个问题已经解决了。 <一href=\"http://blogs.msdn.com/b/webdev/archive/2014/02/28/announcing-the-release-of-dynamic-data-provider-and-entitydatasource-control-for-entity-framework-6.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/webdev/archive/2014/02/28/announcing-the-release-of-dynamic-data-provider-and-entitydatasource-control-for-entity-framework-6.aspx
我试图按照上面的链接。首先,我创建的.edmx模型
用的NuGet安装新EntityDataSource CONTRO
我添加了两个EntityDataSource控制和改变其中的一个preFIX到EF。所以,我有两个控制其中一个是老,另一个是新的更新
当我点击老一我可以看到配置弹出并达到配置数据源屏幕。但在新一按时候没有弹出。所以,我怎么可以配置数据源?
有什么不对呢?
Web.config文件
&LT;?XML版本=1.0&GT?;
&LT;! -
有关如何配置ASP.NET应用程序的更多信息,请访问:
http://go.microsoft.com/fwlink/?LinkId=169433
- &GT;
&LT;结构&gt;
&LT; configSections&GT;
&LT;! - 有关Entity Framework的配置的详细信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - &GT;
&lt;节名称=的EntityFrameworkTYPE =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,的EntityFramework,版本6.0.0.0 =文化=中性公钥= b77a5c561934e089requirePermission =FALSE/&GT;
&LT; / configSections&GT;
&LT;&的System.Web GT;
&LT;编译调试=真targetFramework =4.5&GT;
&LT;&集会GT;
&LT;添加组件=System.Web.Entity,版本= 4.0.0.0,文化=中性公钥= B77A5C561934E089/&GT;
&LT;添加组件=System.Data.Entity的,版本= 4.0.0.0,文化=中性公钥= B77A5C561934E089/&GT;
&LT; /组件&GT;
&LT; /编译&GT;
&LT;的httpRuntime targetFramework =4.5/&GT;
&LT;网页和GT;
&LT;控制与GT;
&LT;添加标签preFIX =EF集结号=Microsoft.AspNet.EntityDataSource命名空间=Microsoft.AspNet.EntityDataSource/&GT;
&LT; /控制&GT;
&LT; /页&GT;
&LT; /system.web>
&LT;&是connectionStrings GT;
&LT;添加名称=SampleDbEntities connectionString=\"metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider连接字符串=安培; QUOT;数据源= OMER-HP \\ SQLEX preSS2014OK;初始目录= SAMPLEDB;集成安全=真; MultipleActiveResultSets = TRUE;应用=&的EntityFramework放大器; QUOT;的providerName =System.Data.EntityClient /&GT;
&LT; /&是connectionStrings GT;
&LT;&的EntityFramework GT;
&LT; defaultConnectionFactory TYPE =System.Data.Entity.Infrastructure.LocalDbConnectionFactory,的EntityFramework&GT;
&LT;&参数GT;
&LT;参数值=mssqllocaldb/&GT;
&LT; /参数&GT;
&LT; / defaultConnectionFactory&GT;
&LT;供应商&GT;
&LT;供应商invariantName =System.Data.SqlClient的TYPE =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/&GT;
&LT; /供应商&GT;
&LT; /&的EntityFramework GT;
&LT; /结构&gt;
Default.aspx的:
&LT;%@页面语言=C#AutoEventWireup =真codeBehind =Default.aspx.cs继承=WebApplication6.Default%GT;&LT;!DOCTYPE HTML&GT;&LT; HTML的xmlns =http://www.w3.org/1999/xhtml&GT;
&LT;头=服务器&GT;
&LT;标题&GT;&LT; /标题&GT;
&LT; /头&GT;
&LT;身体GT;
&LT;表ID =form1的=服务器&GT;
&LT; DIV&GT; &LT; EF:EntityDataSource ID =EntityDataSourceNew=服务器&GT;
&LT; / EF:EntityDataSource&GT;
&LT; BR /&GT;
&LT; ASP:EntityDataSource ID =EntityDataSourceOld=服务器&GT;
&LT; / ASP:EntityDataSource&GT; &LT; / DIV&GT;
&LT; /表及GT;
&LT; /身体GT;
&LT; / HTML&GT;
使用EF6时,不支持用户界面。我们不再建议使用实体数据源为新的项目,所以我们只是做的工作,以提供与EF6可使用的数据源。您需要直接在标记进行配置。
I am learning ASP.NET. I came to EntityDataSorce control. I am using EF6. I have read that this control and EF6 have some issues, conflicts, but with the last update to EntityDataSource this issue has solved. http://blogs.msdn.com/b/webdev/archive/2014/02/28/announcing-the-release-of-dynamic-data-provider-and-entitydatasource-control-for-entity-framework-6.aspx
I am trying to follow above link. First I create an .edmx model
Install new EntityDataSource Contro with NuGet
I added two EntityDataSource controls and changed prefix of one of them to ef. So I have two control one of them is old and other one is new updated
When I click the old one I can see the configuration popup and reach the Configure Data Source screen. But when click on the new one there is no popup. So, how can I configure data source? What is wrong with this?
Web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5"/>
<pages>
<controls>
<add tagPrefix="ef" assembly="Microsoft.AspNet.EntityDataSource" namespace="Microsoft.AspNet.EntityDataSource"/>
</controls>
</pages>
</system.web>
<connectionStrings>
<add name="SampleDbEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=OMER-HP\SQLEXPRESS2014OK;initial catalog=SampleDb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
</configuration>
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication6.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ef:EntityDataSource ID="EntityDataSourceNew" runat="server">
</ef:EntityDataSource>
<br />
<asp:EntityDataSource ID="EntityDataSourceOld" runat="server">
</asp:EntityDataSource>
</div>
</form>
</body>
</html>
The user interface isn't supported when using EF6. We no longer recommend using the Entity Data Source for new projects, so we just did the work to provide a data source that is usable with EF6. You need to perform configuration directly in the markup.
这篇关于EntityDataSource和Entity Framework 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!