Hi Imar
Thank you for this informative book. I need your help on Chapter 14. When I try to open
All.aspx I get the following error:
Server Error in '/xxxxxxxxx' Application.
The type 'Review' is not attributed with EdmEntityTypeAttribute but is contained in an assembly attributed with EdmSchemaAttribute. POCO entities that do not use EdmEntityTypeAttribute cannot be contained in the same assembly as non-POCO entities that use EdmEntityTypeAttribute.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The type 'Review' is not attributed with EdmEntityTypeAttribute but is contained in an assembly attributed with EdmSchemaAttribute. POCO entities that do not use EdmEntityTypeAttribute cannot be contained in the same assembly as non-POCO entities that use EdmEntityTypeAttribute.
Source Error:
Line 7: Using myEntities As New PlanetWroxEntities()
Line 8:
Line 9:
Dim authorizedReviews = From review In myEntities.Reviews
Line 10: Where review.Authorized = True
Line 11: Order By review.CreateDateTime Descending
Source File: C:\inetpub\wwwroot\xxxxxxxxx\All.aspx.
vb Line: 9
Stack Trace:
[InvalidOperationException: The type 'Review' is not attributed with EdmEntityTypeAttribute but is contained in an assembly attributed with EdmSchemaAttribute. POCO entities that do not use EdmEntityTypeAttribute cannot be contained in the same assembly as non-POCO entities that use EdmEntityTypeAttribute.]
System.Data.Entity.Internal.InternalContext.Update EntitySetMappingsForType(Type entityType) +148
System.Data.Entity.Internal.InternalContext.GetEnt itySetAndBaseTypeForType(Type entityType) +38
System.Data.Entity.Internal.Linq.InternalSet`1.Ini tialize() +52
System.Data.Entity.Internal.Linq.InternalSet`1.get _InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System .Linq.IQueryable.get_Provider() +37
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +63
Reviews_All.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\xxxxxxxxx\Reviews\All.aspx.
vb:9
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
Here is the source code:
All.aspx
Code:
<%@ Page Title="All Reviews" Language="VB" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="false" CodeFile="All.aspx.vb" Inherits="Reviews_All" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="Server">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</asp:Content>
All.aspx.vb
Code:
Imports PlanetWroxModel
Partial Class Reviews_All
Inherits BasePage
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Using myEntities As New PlanetWroxEntities()
Dim authorizedReviews = From review In myEntities.Reviews
Where review.Authorized = True
Order By review.CreateDateTime Descending
Select review
GridView1.DataSource = authorizedReviews
GridView1.DataBind()
End Using
End Sub
Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
End Sub
End Class
Please help me solve this POCO Problem.
Thank you