Click here to Skip to main content
15,894,955 members
Articles / Programming Languages / Visual Basic

Template for generating POCO classes with Notify in Entity Framework 4.1

Rate me:
Please Sign up or sign in to vote.
4.60/5 (5 votes)
18 Oct 2011CPOL13 min read 23.7K   142   15  
Added property change notification and validation code to Microsoft’s VB.NET text transform files that create the POCO classes and DBConext class.
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="EntityModel.Annotations.NotifySchema"
                  targetNamespace="http://EntityModel.Annotations.Notify"
                  elementFormDefault="unqualified"
                  xmlns="http://EntityModel.Annotations.Notify"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:documentation xml:lang="en">
      This schema defines additional attributes for the entity conceptual model schema.
      These additional attributes override the default transform behavior of the files from
      the project item template “ADO.NET DbConext Generator with Notify” .
    </xs:documentation>
  </xs:annotation>
  
  <xs:attribute name="GeneratePropertyNotify" type="xs:boolean" >
    <xs:annotation>
      <xs:documentation xml:lang="en">
        GeneratePropertyNotify attribute is used to override default property code generation in entity and complex types.
        Default behavior: Will generating notify and validation code for all properties except:
        •	Navigation properties with the principal role(An entity collection property).
        •	(Primary) key properties.
        •	Foreign key properties.
        •	Updatable complex properties (Setter access of public or internal).
        •	“Read only” non-complex properties (Setter access of private or protected).
        Where used:
        •	Any property and any navigation property as the dependent role (A entity reference property)
        •	Any entity type or complex type. In this case, “false” will turn off default behavior for all of the type’s properties.
      </xs:documentation>
    </xs:annotation>
  </xs:attribute>

  <xs:attribute name="GenerateEntityValidation" type="xs:boolean" >
    <xs:annotation>
      <xs:documentation>
        GenerateEntityValidation attribute is used to override default code generation in the entity container.
        Default behavior: For each entity type, create a partial entity validation method that is invoked by SaveChanges.
        Where used:
            •	Any entity type.
            •	The entity container. In this case, “false” will turn off default behavior for all entity types.
      </xs:documentation>
    </xs:annotation>
  </xs:attribute>
  
</xs:schema>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions