I created the following class to store my entities meta data. However, when I enable dynamic data I have to call the
FvGeneralUser.EnableDynamicData(typeof(generalUserMetadata))
to make it work; The tutorial on asp.net/learn says to call generalUser but when I do this it doesn't work.
What am I doing wrong?
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace App_Code
{
[MetadataType(typeof(generalUserMetadata))]
public partial class generalUser
{ }
public class generalUserMetadata
{
[StringLength(5, ErrorMessage = "First name must be 25 characters or less in length.")]
[Required(ErrorMessage = "First name is required!!!")]
public String firstName { get; set; }
}
}
Where you "enable dynamic data"????? do you mean the metadata does not effect when run project?
Open .edmx file (model) and check the entity name; which should have "generalUser" if the name is not same sometime EF leas "s" suffix itself so that is why i am telling you to check.
Hi Cooper88, I suspect that your metadata is not in scope please add a bogus property to you metadata and with out explicitly enabling DD you will get no error which should happen with a bogus property in your metadata.
This issue is always because the metadata is not in scope.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
cooper88
Member
116 Points
103 Posts
entity framework and dynamic data
Nov 17, 2011 12:43 AM|LINK
I created the following class to store my entities meta data. However, when I enable dynamic data I have to call the
FvGeneralUser.EnableDynamicData(typeof(generalUserMetadata)) to make it work; The tutorial on asp.net/learn says to call generalUser but when I do this it doesn't work.
What am I doing wrong?
using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace App_Code { [MetadataType(typeof(generalUserMetadata))] public partial class generalUser { } public class generalUserMetadata { [StringLength(5, ErrorMessage = "First name must be 25 characters or less in length.")] [Required(ErrorMessage = "First name is required!!!")] public String firstName { get; set; } } }pratiksolank...
Member
270 Points
73 Posts
Re: entity framework and dynamic data
Nov 17, 2011 02:32 AM|LINK
hi,
Where you "enable dynamic data"????? do you mean the metadata does not effect when run project?
Open .edmx file (model) and check the entity name; which should have "generalUser" if the name is not same sometime EF leas "s" suffix itself so that is why i am telling you to check.
public partial class generalUser
{ }
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: entity framework and dynamic data
Nov 17, 2011 12:41 PM|LINK
Hi Cooper88, I suspect that your metadata is not in scope please add a bogus property to you metadata and with out explicitly enabling DD you will get no error which should happen with a bogus property in your metadata.
This issue is always because the metadata is not in scope.
Always seeking an elegant solution.