This project is read-only.

Sequence contains no matching element

Jun 1, 2016 at 4:25 PM
Hi Chris,

I like what you did with dynamicmvc.

Unfortunately, I'm unable to get it working using the completed tutorial version 3.0. Switching the tutorial example out with it out to use a different data source (i.e. connection string, code first, DBSet). Here's what I did.
  1. Download completed tutorial
  2. Add ADO.NET Entity Data Model call "ReferenceTablesDbContext" using the Code First from database option and saved to the Models folder
  3. Generate model classes from DB and saved to the Models folder.
  4. Add [DynamicEntity] and [DynamicMenuItem("ClassNameHere", "Order Entry")] to all generated classes
  5. Change "DefaultConnection" to "ReferenceTablesDbContext" (name of connection string) in the IdentityModels.cs file. Update file to reflect DBSet<ClassNameHere> properties to reflect generated code.
  6. Run and Debug solution
  7. Exception in Global.asax.cs for DynamicMVCContext.DynamicMvcManager.RegisterDynamicMvc();
Stack trace....
Error: {"Sequence contains no matching element"} at GetDynamicEntityMetadatas() below.
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at DynamicMVC.DynamicEntityMetadataLibrary.Strategies.DynamicEntityMetadataBuilderHelper.DefaultPropertyBuilderHelper.Build(DynamicEntityMetadata dynamicEntityMetadata, EntityMetadata entityMetadata) in c:\CodePlex\DynamicMVC\DynamicMVC-vNext\DynamicMVC.DynamicEntityMetadataLibrary\Strategies\DynamicEntityMetadataBuilderHelper\DefaultPropertyBuilderHelper.cs:line 25
   at DynamicMVC.DynamicEntityMetadataLibrary.Builders.DynamicEntityMetadataBuilder.GetDynamicEntityMetadata(IEnumerable`1 entityMetadatas, String typeName) in c:\CodePlex\DynamicMVC\DynamicMVC-vNext\DynamicMVC.DynamicEntityMetadataLibrary\Builders\DynamicEntityMetadataBuilder.cs:line 61
   at DynamicMVC.DynamicEntityMetadataLibrary.Builders.DynamicEntityMetadataBuilder.Build(IEnumerable`1 entityMetadatas) in c:\CodePlex\DynamicMVC\DynamicMVC-vNext\DynamicMVC.DynamicEntityMetadataLibrary\Builders\DynamicEntityMetadataBuilder.cs:line 32
   at DynamicMVC.DynamicEntityMetadataLibrary.DynamicEntityMetadataManager.GetDynamicEntityMetadatas() in c:\CodePlex\DynamicMVC\DynamicMVC-vNext\DynamicMVC.DynamicEntityMetadataLibrary\DynamicEntityMetadataManager.cs:line 30
   at DynamicMVC.UI.DynamicMVC.Managers.DynamicMvcManager.RegisterDynamicMvc() in c:\Users\me\Downloads\Tutorial1Complete\OrderEntryDemo\OrderEntryDemo\DynamicMVC\Managers\DynamicMvcManager.cs:line 35
   at OrderEntryDemo.MvcApplication.Application_Start() in c:\Users\me\Downloads\Tutorial1Complete\OrderEntryDemo\OrderEntryDemo\Global.asax.cs:line 42
Do you know what am I doing wrong? I appreciate any help or guidance!
Jun 2, 2016 at 10:42 PM
I'm curious if anyone was able to get dynamicmvc working with an existing database using EF code first generated models. Thanks
Jun 3, 2016 at 6:04 PM
Issue solved. Same problem as the other previous posts. Id property required for it to work.