I have an ASP.NET 4 Dynamic Data website that works with a fairly simple set of database tables that display through the Entity Framework model in a different assembly. I do not want to throw all the tables in the EF model, so in my global.asax file, I initialized the default model as follows:
DefaultModel.RegisterContext( typeof( MyCompany.MyProject.DataModel.DataContext ), new ContextConfiguration() { ScaffoldAllTables = false } );
MSDN docs (and comments in the global.asax file) say that now I should be able to selectively include the scaffolds of individual tables by adding the [ScaffoldTable(true)] attribute to their partial buddy class. I did like this:
using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Web.DynamicData; namespace MyCompany.MyProject.DataModel { [MetadataType( typeof( InHouseClaimMetadata ) )] [ScaffoldTable( true )] public partial class InHouseClaim { [DisplayName( "In-House Claims" )] [TableName( "In-House Claims" )] public class InHouseClaimMetadata { [DisplayName( "Reporting Date" )] public object ReportingDate { get; set; }
But when loading Default.aspx, the following error message appears:
No tables available. Make sure that at least one data model is registered in Global.asax, and that scaffolding is enabled or custom pages are implemented.
I got this to work in similar scenarios before; one thing that differs from this attempt is that my EF model is its own assembly. If I modify global.asax to move forward and align all tables, it works fine. But obviously I do not want this. I was careful to make sure that the namespace for the partial metadata class matches the EF data context namespace.
So I'm at a dead end ...
source share