I’m trying to add a Metadata partial class to an existing MVC using EF 4.3 and I don’t know where to add the class. I’m going throgh the DBFirstMVC tutorial which has Blogs, Posts and Comments. I want to add some validation to the Blog class and after researching on how to do it I see I should add a new Partial Class Blog decorating it with
MetadataType(typeof(BlogMetaData))]
It is supposed to go in the same namespace as Blog but when I try to add a class to the Model folder I get a popup saying it already exists do I want to overwrite it. If I say no, I can’t create it. Where physically does the Metadata class go?
You can create a metadata folder an drop the files in it just be sure you keep the same namespace. The location doesnt much matter. You could actually name the file BlogMetadata and include your partial declaration and the metadataclass in it – some choose this approach too.