Answered by:
DD 4.0 Preview 2- issue starting webapp?

Question
-
User-720002110 posted
Hi, I've spent a few hours today trying to get an existing web app to run under DynamicData v4 preview 2. I've solved almost everything... except an unknown issue with the routing when trying to run the web site.
The problem is: if I use the System.Web.DynamicData assembly from the .NET 3.5 SP1 download, it starts and works fine.
If I replace it with the System.Web.DynamicData assembly from the Preview 2 download (and alter the web.config file), I get a 404 error.
It looks like the routing is failing- although I've checked that, and isolated the issue to simple replacing the System.Web.DyamicData assembly.
I've seen a few references to issues, which I've checked.
- web.config includes a <httpModule> reference to System.Web.Rounting
- versions of the assemblies are correct in web.config
- cross-checked the web.config against samples from preview 2 download (several times)
- the same issue happens on Vista as XP
I'm at a loss- can anyone suggest what might be causing the 404 error when using the Preview 2 System.Web.DynamicData assembly?
Thanks,
+M
Saturday, December 27, 2008 7:35 AM
Answers
-
User1641955678 posted
Note that you need more than just the new System.Web.DynamicData.dll. You also need System.ComponentModel.DataAnnotations.dll and Microsoft.Web.Extensions.dll.
One thing I'd try is to see your debugger to break on all exception, and start debugging the app (F5). You may get some interesting exceptions that point to the issue. You may also see some benign exception, so don't stop at the first one.
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 27, 2008 3:35 PM -
User1641955678 posted
That shouldn't be the case, and if you look at the 'SampleProject' app that's included, the table names are still pluralized. There is however one exception: when dealing with a model that uses entity inheritance, you end up with multiple entity types sharing a single entity set. In that case, we do use the entity type for the name, and it may be singular. e.g. in that same SampleProject, this occurs for entities that come from InheritanceEF.edmx.
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 27, 2008 8:59 PM
All replies
-
User1641955678 posted
Note that you need more than just the new System.Web.DynamicData.dll. You also need System.ComponentModel.DataAnnotations.dll and Microsoft.Web.Extensions.dll.
One thing I'd try is to see your debugger to break on all exception, and start debugging the app (F5). You may get some interesting exceptions that point to the issue. You may also see some benign exception, so don't stop at the first one.
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 27, 2008 3:35 PM -
User-720002110 posted
Thanks- the exceptions didn't turn anything up, however I've looked for a few more hours and found perhaps something different happening with the way EF entities are handled with the new assemblies.
I have an entitiy "Results" which in the EF CSDL is "<EntitySet Name="Results" EntityType="DataModel.Result" />". I have a partial class "Result", which represents a single result (member of the Results set). In the Result partial class, I have some business logic and a metadata class which defines attributes. All pretty normal as far as I can tell.
I used to browse to "localhost:{port}/Results/List.aspx". This works with the old assemblies. If I change to the new assemblies, it no longer works, HOWEVER "localhost:{port}/Result/List.aspx" (note the lack of pluralisation) does bring up a page (although with another error related to not finding the Results entity- it seems to be looking for an entity called Result in numerous places).
I've created a new dynData app from scratch & attached the data model (which is in it's own assembly), and done a default scaffolding, and confirmed that while the EF model includes pluralised results sets, perhaps entities are now referred to in the singular (not pluralised)?
Could something have changed in the way Entity Framework tables (entities) are handled?
+M
Saturday, December 27, 2008 6:38 PM -
User1641955678 posted
That shouldn't be the case, and if you look at the 'SampleProject' app that's included, the table names are still pluralized. There is however one exception: when dealing with a model that uses entity inheritance, you end up with multiple entity types sharing a single entity set. In that case, we do use the entity type for the name, and it may be singular. e.g. in that same SampleProject, this occurs for entities that come from InheritanceEF.edmx.
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 27, 2008 8:59 PM -
User1641955678 posted
Also, note that whatever the names end up being, the list shown in default.aspx should match and produce the correct URL.
David
Saturday, December 27, 2008 9:01 PM -
User-720002110 posted
Thanks David, the tips have helped me sort it out.
The reason I believe the SampleProject works, is the entity set name is the same as the entity type name, and both are plural. For example, from the SampleProject Northwind.edmx CSDL: <EntitySet Name="Categories" EntityType="DynamicDataEFProject.Categories" />
However, this is what I'm working with in my CSDL: <EntitySet Name="Results" EntityType="DataModel.Result" />
Note that I use plural for the entity set, however singular for the entity type. This makes more sense in my c# code, where I refer to a "Result" as a single entity record, however when looking at the data context, I get a property called "Results" from which to query against.
When I change the entity type to "Results" (matching the pattern from Northwind.edmx where both are pluralised), Preview 2 DD works correctly. So I have a workaround... however my CSDL worked correctly under the v3.5 SP1 release- it appears to fail under Preview 2, where Preview 2 seems to get confused from the mixed references (which also causes issues with the default.aspx file, by the way).
Cheers,
+M
Tuesday, December 30, 2008 6:28 AM -
User-1005219520 posted
Hi +M,
Try to reproduce the problem using only the Results table (in a new web project). If you can reproduce the problem, post the T-SQL to create the table and I'll investigate from this end.
Tuesday, December 30, 2008 3:05 PM -
User-720002110 posted
Hi Rick, below is the DDL for the table. In addition, there are two other sets of changes: (1) the edmx file (below), (2) the web.config file (to use the preview-2 DLLs- I believe I've done a standard change to use the preview-2 DLLs).
Generate the standard EDMX for the table, then replace the CSDL and mappings in the text below. It's these mappings (manually modified from the generated EDMX) which cause the issue. Open the default site, click on the table: for me, I get an ArgumentException in the List.aspx Page_Load: "The context 'WebApp1.ResultsOnlyEntities' does not have a table with the context-specific name 'Results'"
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tblResult]( [ResultId] [int] IDENTITY(1,1) NOT NULL, [Context] [nvarchar](50) NULL, [StartText] [nvarchar](50) NULL, [ResultText] [nvarchar](50) NULL, [SaveTimeStamp] [datetime] NOT NULL, CONSTRAINT [PK_tblResult] PRIMARY KEY CLUSTERED ( [ResultId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[tblResult] ADD CONSTRAINT [DF_tblResult_SaveTimeStamp] DEFAULT (getdate()) FOR [SaveTimeStamp] GO
EDMX:
<!-- CSDL content --> <edmx:ConceptualModels> <Schema Namespace="ResultsOnlyModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm"> <EntityContainer Name="ResultsOnlyEntities"> <EntitySet Name="Results" EntityType="ResultsOnlyModel.Result" /> </EntityContainer> <EntityType Name="Result"> <Key> <PropertyRef Name="ResultId" /> </Key> <Property Name="ResultId" Type="Int32" Nullable="false" /> <Property Name="Context" Type="String" MaxLength="50" Unicode="true" FixedLength="false" /> <Property Name="StartText" Type="String" MaxLength="50" Unicode="true" FixedLength="false" /> <Property Name="ResultText" Type="String" MaxLength="50" Unicode="true" FixedLength="false" /> <Property Name="SaveTimeStamp" Type="DateTime" Nullable="false" /> </EntityType> </Schema> </edmx:ConceptualModels> <!-- C-S mapping content --> <edmx:Mappings> <Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"> <EntityContainerMapping StorageEntityContainer="ResultsOnlyModelStoreContainer" CdmEntityContainer="ResultsOnlyEntities"> <EntitySetMapping Name="Results"> <EntityTypeMapping TypeName="IsTypeOf(ResultsOnlyModel.Result)"> <MappingFragment StoreEntitySet="tblResult"> <ScalarProperty Name="ResultId" ColumnName="ResultId" /> <ScalarProperty Name="Context" ColumnName="Context" /> <ScalarProperty Name="StartText" ColumnName="StartText" /> <ScalarProperty Name="ResultText" ColumnName="ResultText" /> <ScalarProperty Name="SaveTimeStamp" ColumnName="SaveTimeStamp" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> </EntityContainerMapping> </Mapping> </edmx:Mappings>
Thursday, January 1, 2009 6:11 AM -
User-1005219520 posted
Hey Mark,
I don't think you have renamed your entity consistently. Results is also a poor choice - ambiguous to the reader at best. At any rate you have a pure EF problem here, not dynamic data. The only question is where there is a collision with the name results. Is there any reason you need to change the entity name? Why not stick with tblResult? If you really want to solve the problem - test your modified model in a console application and post the problem to http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/threads/
Friday, January 2, 2009 2:13 PM -
User-720002110 posted
Thanks Rick- in the context of my app the term Results had a specific reason for existing- anyway, I've changed the EF so it now works under preview 2. While I don't understand why it's an EF problem when the EF works under the released version of DD but fails in preview 2, it's a moot point- I've got a workaround and am going again. I certainly do appreciate your comments & blog: as I'm learning DD they're very helpful, so thank you.
+Mark
Friday, January 2, 2009 7:17 PM