【发布时间】:2014-11-08 07:26:43
【问题描述】:
我正在学习 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 控件
我添加了两个 EntityDataSource 控件并将其中一个的前缀更改为 ef。所以我有两个控件,一个是旧的,另一个是新的更新
当我点击旧的时,我可以看到配置弹出窗口并到达配置数据源屏幕。但是当点击新的时没有弹出窗口。那么,如何配置数据源呢? 这有什么问题?
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>
默认.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>
【问题讨论】:
-
删除 EntityDataSource 并重新添加。它可能会起作用
-
这也可能对您有所帮助。 stackoverflow.com/questions/19792144/…
-
@Seminda 不幸的是,他们没有帮助
标签: c# asp.net entity-framework entity-framework-6