EntityDataSource和Entity Framework 6 [英] EntityDataSource and Entity Framework 6

查看:115
本文介绍了EntityDataSource和Entity Framework 6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习ASP.NET。我来到了EntityDataSorce控件。我使用的是EF6。我读过这个控件和EF6有一些问题,冲突,但是最后更新到EntityDataSource这个问题已经解决了。 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控件,并将其中一个更改为ef的前缀。所以我有两个控件其中一个是旧的,另一个是新的更新





当我点击旧的,我可以看到配置弹出窗口并进入配置数据源屏幕。但是当点击新的时候,没有弹出窗口。那么如何配置数据源?
这是什么问题?





Web.config

  xml version =1.0?> 
<! -
有关如何配置ASP.NET应用程序的更多信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
- >
< configuration>
< configSections>
<! - 有关实体框架配置的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >
< section name =entityFrameworktype =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089requirePermission =false/> ;
< / configSections>
< system.web>
< compilation debug =truetargetFramework =4.5>
< assembly>
< 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 =efassembly =Microsoft.AspNet.EntityDataSourcenamespace =Microsoft.AspNet.EntityDataSource/>
< / controls>
< / pages>
< /system.web>
< connectionStrings>
< add name =SampleDbEntitiesconnectionString =metadata = res://*/Model1.csdl | res://*/Model1.ssdl | res://*/Model1.msl; provider = System .Data.SqlClient; provider connection string =& quot; data source = OMER-HP\SQLEXPRESS2014OK; initial catalog = SampleDb; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework& quot;的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.SqlClienttype =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/>
< / providers>
< / entityFramework>
< / configuration>

Default.aspx:

 <%@ Page Language =C#AutoEventWireup =trueCodeBehind =Default.aspx.csInherits =WebApplication6.Default%> 

<!DOCTYPE html>

< html xmlns =http://www.w3.org/1999/xhtml>
< head runat =server>
< title>< / title>
< / head>
< body>
< form id =form1runat =server>
< div>

< ef:EntityDataSource ID =EntityDataSourceNewrunat =server>
< / ef:EntityDataSource>
< br />
< asp:EntityDataSource ID =EntityDataSourceOldrunat =server>
< / asp:EntityDataSource>

< / div>
< / form>
< / body>
< / html>


解决方案

使用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=&quot;data source=OMER-HP\SQLEXPRESS2014OK;initial catalog=SampleDb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 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屋!

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