Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Tweaks. v2.1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
msawczyn committed Sep 25, 2020
1 parent 3d82223 commit b112a03
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 467 deletions.
Binary file modified dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix
Binary file not shown.
383 changes: 164 additions & 219 deletions src/Dsl/CustomCode/Rules/ModelAttributeChangeRules.cs

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions src/Dsl/CustomCode/Rules/ModelRootChangeRules.cs
Expand Up @@ -106,20 +106,6 @@ public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
}
}

List<ModelAttribute> attributes = store.ElementDirectory
.AllElements
.OfType<ModelAttribute>()
.Where(a => a.PropertyType == PropertyType.DatabaseComputed)
.ToList();

message = $"This will change {attributes.Count} class attribute{(attributes.Count == 1 ? "" : "s")} from DatabaseComputed to Computed. Are you sure?";

if (attributes.Any() && BooleanQuestionDisplay.Show(store, message) == true)
{
foreach (ModelAttribute modelAttribute in attributes)
modelAttribute.PropertyType = PropertyType.Computed;
}

break;
}
}
Expand Down
159 changes: 0 additions & 159 deletions src/Dsl/CustomCode/Type Converters/PropertyTypeTypeConverter.cs

This file was deleted.

Expand Up @@ -61,7 +61,6 @@ private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
if (modelRoot.EntityFrameworkVersion == EFVersion.EF6)
{
propertyDescriptors.Remove("PropertyAccessMode");
propertyDescriptors.Remove("PropertyType");
}

// don't display BackingField or PropertyAccessMode unless AutoProperty is false
Expand All @@ -71,51 +70,6 @@ private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
propertyDescriptors.Remove("PropertyAccessMode");
}

// Lots goes away for computed and database-computed properties
if (modelAttribute.PropertyType == PropertyType.Computed)
{
propertyDescriptors.Remove("AutoProperty");
propertyDescriptors.Remove("BackingFieldName");
propertyDescriptors.Remove("ColumnName");
propertyDescriptors.Remove("ColumnType");
propertyDescriptors.Remove("DatabaseCollation");
propertyDescriptors.Remove("IdentityType");
propertyDescriptors.Remove("Indexed");
propertyDescriptors.Remove("IndexedUnique");
propertyDescriptors.Remove("InitialValue");
propertyDescriptors.Remove("IsConcurrencyToken");
propertyDescriptors.Remove("IsIdentity");
propertyDescriptors.Remove("MinLength");
propertyDescriptors.Remove("MaxLength");
propertyDescriptors.Remove("Persistent");
propertyDescriptors.Remove("PropertyAccessMode");
propertyDescriptors.Remove("Required");

}
else if (modelAttribute.PropertyType == PropertyType.DatabaseComputed)
{
propertyDescriptors.Remove("AutoProperty");
propertyDescriptors.Remove("BackingFieldName");
propertyDescriptors.Remove("ColumnName");
propertyDescriptors.Remove("ColumnType");
propertyDescriptors.Remove("DatabaseCollation");
propertyDescriptors.Remove("IdentityType");
propertyDescriptors.Remove("Indexed");
propertyDescriptors.Remove("IndexedUnique");
propertyDescriptors.Remove("InitialValue");
propertyDescriptors.Remove("IsConcurrencyToken");
propertyDescriptors.Remove("IsIdentity");
propertyDescriptors.Remove("MinLength");
propertyDescriptors.Remove("MaxLength");
propertyDescriptors.Remove("Persistent");
propertyDescriptors.Remove("PropertyAccessMode");
propertyDescriptors.Remove("Required");

propertyDescriptors.Remove("ImplementNotify");
propertyDescriptors.Remove("ReadOnly");
propertyDescriptors.Remove("SetterVisibility");
}

/********************************************************************************/

//Add the descriptors for the tracking properties
Expand Down
Expand Up @@ -24,7 +24,6 @@ private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
propertyDescriptors.Remove("AutomaticMigrationsEnabled");
propertyDescriptors.Remove("ProxyGenerationEnabled");
propertyDescriptors.Remove("DatabaseType");
propertyDescriptors.Remove("InheritanceStrategy");

if (modelRoot.GetEntityFrameworkPackageVersionNum() < 2.1)
propertyDescriptors.Remove("LazyLoadingEnabled");
Expand Down
1 change: 0 additions & 1 deletion src/Dsl/Dsl.csproj
Expand Up @@ -153,7 +153,6 @@
<Compile Include="CustomCode\Type Converters\MinLengthTypeConverter.cs" />
<Compile Include="CustomCode\Type Converters\EndpointRoleTypeConverter.cs" />
<Compile Include="CustomCode\Type Converters\PropertyAccessModeTypeConverter.cs" />
<Compile Include="CustomCode\Type Converters\PropertyTypeTypeConverter.cs" />
<Compile Include="CustomCode\Type Descriptors\AssociationTypeDescriptor.cs" />
<Compile Include="CustomCode\Partials\BidirectionalAssociation.cs" />
<Compile Include="CustomCode\Connection Builders\BidirectionalAssociationBuilder.cs" />
Expand Down
7 changes: 0 additions & 7 deletions src/DslPackage/DslPackage.csproj
Expand Up @@ -198,12 +198,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>ValidationExtensionRegistrar.tt</DependentUpon>
</Compile>
<Compile Include="TextTemplates\EditingOnly\EF6Designer.cs" />
<Compile Include="TextTemplates\EditingOnly\EFCoreDesigner.cs" />
<Compile Include="TextTemplates\EditingOnly\EFDesigner.cs" />
<Compile Include="TextTemplates\EditingOnly\MultipleOutputHelper.cs" />
<Compile Include="TextTemplates\EditingOnly\TextTransformation.cs" />
<Compile Include="TextTemplates\EditingOnly\VSIntegration.cs" />
<Compile Include="VSPackage.Designer.cs" />
<Content Include="Logo.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down Expand Up @@ -362,7 +356,6 @@
<Content Include="TextTemplates\EFDesigner.ttinclude">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<None Include="TextTemplates\EditingOnly\_ReadMe.md" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dsl\Dsl.csproj">
Expand Down
Binary file modified src/DslPackage/Parsers/EF6Parser.exe
Binary file not shown.
Binary file modified src/DslPackage/Parsers/EFCore2Parser.exe
Binary file not shown.
Binary file modified src/DslPackage/Parsers/EFCore3Parser.exe
Binary file not shown.
32 changes: 15 additions & 17 deletions src/DslPackage/ProjectItemTemplates/EFModel.xsd
Expand Up @@ -550,6 +550,12 @@
<xsd:documentation>If true (the default), code will be generated for this class. If false, it is assumed to be referenced from another assembly.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<!-- Property: IsPropertyBag -->
<xsd:attribute name="isPropertyBag" type="xsd:boolean" >
<xsd:annotation>
<xsd:documentation>If true, this class will be implemented as Dictionary&lt;string, object&gt;</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down Expand Up @@ -784,12 +790,6 @@
<xsd:documentation>Defines how EF reads and write this property or its backing field. See https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.propertyaccessmode</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<!-- Property: PropertyType -->
<xsd:attribute name="propertyType" type="PropertyType" >
<xsd:annotation>
<xsd:documentation>Normal persistant property, computed property or property computed at the database</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down Expand Up @@ -2342,22 +2342,20 @@
</xsd:restriction>
</xsd:simpleType>

<!-- Enum PropertyType -->
<xsd:simpleType name="PropertyType">
<!-- Enum PropertyExposure -->
<xsd:simpleType name="PropertyExposure">
<xsd:annotation>
<xsd:documentation>How the code generator will present this property to Entity Framework (EFCore5+ only)</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Normal">
<xsd:annotation>
<xsd:documentation>This is a normal persistant property</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="Computed">
<xsd:enumeration value="Property">
<xsd:annotation>
<xsd:documentation>This property is not persisted, but computed at runtime</xsd:documentation>
<xsd:documentation>Generated code will create and use this attribute as a .NET property,</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="DatabaseComputed">
<xsd:enumeration value="Field">
<xsd:annotation>
<xsd:documentation>This property is readonly and created by the database</xsd:documentation>
<xsd:documentation>Generated code will create and use this attribute as a .NET field</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
Expand Down
6 changes: 3 additions & 3 deletions src/DslPackage/TextTemplates/EditingOnly/EFCoreDesigner.cs
Expand Up @@ -133,17 +133,17 @@ void WriteDbContextEFCore(ModelRoot modelRoot)
switch (modelRoot.InheritanceStrategy)
{
case CodeStrategy.TablePerType:
classesWithTables = modelRoot.Classes.Where(mc => !mc.IsDependentType && mc.GenerateCode).OrderBy(x => x.Name).ToArray();
classesWithTables = modelRoot.Classes.Where(mc => (!mc.IsDependentType || !string.IsNullOrEmpty(mc.TableName)) && mc.GenerateCode).OrderBy(x => x.Name).ToArray();

break;

case CodeStrategy.TablePerConcreteType:
classesWithTables = modelRoot.Classes.Where(mc => !mc.IsDependentType && !mc.IsAbstract && mc.GenerateCode).OrderBy(x => x.Name).ToArray();
classesWithTables = modelRoot.Classes.Where(mc => (!mc.IsDependentType || !string.IsNullOrEmpty(mc.TableName)) && !mc.IsAbstract && mc.GenerateCode).OrderBy(x => x.Name).ToArray();

break;

case CodeStrategy.TablePerHierarchy:
classesWithTables = modelRoot.Classes.Where(mc => !mc.IsDependentType && mc.Superclass == null && mc.GenerateCode).OrderBy(x => x.Name).ToArray();
classesWithTables = modelRoot.Classes.Where(mc => (!mc.IsDependentType || !string.IsNullOrEmpty(mc.TableName)) && mc.Superclass == null && mc.GenerateCode).OrderBy(x => x.Name).ToArray();

break;
}
Expand Down

0 comments on commit b112a03

Please sign in to comment.