Entity Framework Designer ExtenderThis tool extends the entity framework designer to support new design time features: • Set the ProxyCreationEnabled Property. • Set the AutoDetectChanges Property • Control over Data Contract attributes (WCF) • Control over the Virtual modifier When the designer area is selected (properties box is pointed to ConceptualEntityModel) 4 new properties are available: ProxyCreationEnabled controls the ProxyCreationEnabled property of the context configuration. AutoDetectChanges controls the AutoDetectChangesEnabled property of the context configuration. Just like with the Lazy Loading, you can change these options manually after the context is created or with the new constructor override provided by the templates associated with this extension. The Data Contract and IsReference are not affecting the context directly but are setting the default for all entities in the model. You can change those options at the entity level if you need fine control over the exposed entities. C# Edit|Remove csharppublic partial class Model1Container1 : DbContext { public Model1Container1() : base("name=Model1Container1") { this.Configuration.LazyLoadingEnabled = false; this.Configuration.AutoDetectChangesEnabled = false; this.Configuration.ProxyCreationEnabled = false; } public Model1Container1(bool lazyLoadingEnabled, bool proxyCreationEnabled, bool autoDetectChangesEnabled) : base("name=Model1Container1") { this.Configuration.LazyLoadingEnabled = lazyLoadingEnabled; this.Configuration.ProxyCreationEnabled = proxyCreationEnabled; this.Configuration.AutoDetectChangesEnabled = autoDetectChangesEnabled; } public partial class Model1Container1 : DbContext { public Model1Container1() : base("name=Model1Container1") { this.Configuration.LazyLoadingEnabled = false; this.Configuration.AutoDetectChangesEnabled = false; this.Configuration.ProxyCreationEnabled = false; } public Model1Container1(bool lazyLoadingEnabled, bool proxyCreationEnabled, bool autoDetectChangesEnabled) : base("name=Model1Container1") { this.Configuration.LazyLoadingEnabled = lazyLoadingEnabled; this.Configuration.ProxyCreationEnabled = proxyCreationEnabled; this.Configuration.AutoDetectChangesEnabled = autoDetectChangesEnabled; } When an entity type or a complex type are selected two new properties are available: Data Contract set to false (IsReference is not applicable): Data Contract set to true (IsReference set to false): [DataContract] public partial classDog : Pet {...} Data Contract set to true (IsReference set to true): [DataContract(IsReference =true)] public partial class Dog : Pet {...} For both properties, if value is set to default, the value set at the container level will be used. When selecting a property the following new options are available: Data member is initially set to default and will inherit its configuration from the parent (entity or complex type). When set to true, the DataMember attribute will be added to the property otherwise it will be omitted (and prevent the property from being serialized) The virtual modifier option only appears when selecting navigation properties and will allow turning the property modifier on or off. EF uses that modifier to setup the lazy loading for that property. For more information about Virtual and lazy loading see Ladislav Mrnka comments on stack overflow. To generate the classes using the new features, set the Code Generation strategy for the model to none and right click on the designer surface and select ‘Add Code Generation Item…’ and then select the new template: “ADO.NET C# Extended DbContext Generator” If you want to see more features added you can make new suggestions and vote on existing ones on the extensionpolling site.
|