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

Commit

Permalink
V3.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
msawczyn committed Oct 10, 2021
1 parent dcbaea0 commit b7ddb0d
Show file tree
Hide file tree
Showing 16 changed files with 406 additions and 27 deletions.
18 changes: 17 additions & 1 deletion README.md
Expand Up @@ -57,11 +57,27 @@ to <a href="https://www.jetbrains.com/?from=EFDesigner"><img src="https://msawcz

### Change Log

**3.0.6**
**3.0.7**

- Fixed a number of issues with importing compiled assemblies
- Fixed coloring of cascade delete associations when flagged on the model (see https://github.com/msawczyn/EFDesigner/issues/291)
- Fixed missing '$' in generator template that was generating bad code for table schemas (see https://github.com/msawczyn/EFDesigner/issues/289)
- Restored auto-instantiation of dependent objects in entity constructors (see https://github.com/msawczyn/EFDesigner/issues/287)
- Added Microsoft.VisualStudio.Modeling.Components.15.0.dll to DslPackage assembly (see https://github.com/msawczyn/EFDesigner/issues/293)
- Removed validations on model open/load that prevented a misconfigured model from loading. Errors will still be shown during editing and when saving.
- New context menu item to add class elements at the cursor position on a diagram (thanks to dcastenholz for the addition)
- New context menu item to generate code from the Solution Explorer (thanks to dcastenholz for the addition)
- Method visibility changes to allow MEF extensions to supply new icons and to layout a diagram (thanks to dcastenholz for the addition)

<details>
<summary><b>3.0.6</b></summary>

- Added ability to copy current diagram to clipboard
- DbContext fix for configuring associations with backing fields
- Code generation fix for associations with backing fields

</details>

<details>
<summary><b>3.0.5</b></summary>

Expand Down
11 changes: 11 additions & 0 deletions VSMarketplace blurb.md
Expand Up @@ -25,6 +25,17 @@ For comprehensive documentation, please visit [the project's documentation site]

**ChangeLog**

**3.0.7**
- **[NEW]** New context menu item to add class elements at the cursor position on a diagram (thanks to dcastenholz for the addition)
- **[NEW]** New context menu item to generate code from the Solution Explorer (thanks to dcastenholz for the addition)
- **[NEW]** Method visibility changes to allow MEF extensions to supply new icons and to layout a diagram (thanks to dcastenholz for the addition)
- Fixed a number of issues with importing compiled assemblies
- Fixed coloring of cascade delete associations when flagged on the model (see https://github.com/msawczyn/EFDesigner/issues/291)
- Fixed missing '$' in generator template that was generating bad code for table schemas (see https://github.com/msawczyn/EFDesigner/issues/289)
- Restored auto-instantiation of dependent objects in entity constructors (see https://github.com/msawczyn/EFDesigner/issues/287)
- Added Microsoft.VisualStudio.Modeling.Components.15.0.dll to DslPackage assembly (see https://github.com/msawczyn/EFDesigner/issues/293)
- Removed validations on model open/load that prevented a misconfigured model from loading. Errors will still be shown during editing and when saving.

**3.0.6**
- **[NEW]** Added ability to copy current diagram to clipboard
- DbContext fix for configuring associations with backing fields
Expand Down
Binary file modified dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix
Binary file not shown.
3 changes: 2 additions & 1 deletion src/Dsl/CustomCode/Rules/ModelClassAddRules.cs
Expand Up @@ -22,8 +22,9 @@ public override void ElementAdded(ElementAddedEventArgs e)
return;

// there could already be an identity property if this class was created via Paste or import
// also, don't add columns to views or query types
// NB: don't do anything if we're in an owned type
if (!element.AllIdentityAttributes.Any() && !element.IsDependentType)
if (!element.AllIdentityAttributes.Any() && !element.IsDependentType && !element.IsDatabaseView && !element.IsQueryType)
{
// there could also be a property named "Id"
ModelAttribute idProperty = element.AllAttributes.FirstOrDefault(a => a.Name == "Id");
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.
Binary file modified src/DslPackage/Parsers/EFCore5Parser.exe
Binary file not shown.
110 changes: 110 additions & 0 deletions src/Testing/Sandbox/Sandbox_EFCore/AppDbContext.generated.cs
@@ -0,0 +1,110 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
//
// Produced by Entity Framework Visual Editor v3.0.7.1
// Source: https://github.com/msawczyn/EFDesigner
// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner
// Documentation: https://msawczyn.github.io/EFDesigner/
// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace SureImpact.Data.Framework
{
/// <inheritdoc/>
public partial class AppDbContext : DbContext
{
#region DbSets
public virtual Microsoft.EntityFrameworkCore.DbSet<global::SureImpact.Data.Framework.TestData> TestDatas { get; set; }
public virtual Microsoft.EntityFrameworkCore.DbSet<global::SureImpact.Data.Framework.TestView> TestViews { get; set; }

#endregion DbSets

/// <summary>
/// Default connection string
/// </summary>
public static string ConnectionString { get; set; } = @"Data Source=.\sqlexpress;Initial Catalog=Test;Integrated Security=True";

/// <summary>
/// <para>
/// Initializes a new instance of the <see cref="T:Microsoft.EntityFrameworkCore.DbContext" /> class using the specified options.
/// The <see cref="M:Microsoft.EntityFrameworkCore.DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)" /> method will still be called to allow further
/// configuration of the options.
/// </para>
/// </summary>
/// <param name="options">The options for this context.</param>
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}

partial void CustomInit(DbContextOptionsBuilder optionsBuilder);

/// <inheritdoc />
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseLazyLoadingProxies();

CustomInit(optionsBuilder);
}

partial void OnModelCreatingImpl(ModelBuilder modelBuilder);
partial void OnModelCreatedImpl(ModelBuilder modelBuilder);

/// <summary>
/// Override this method to further configure the model that was discovered by convention from the entity types
/// exposed in <see cref="T:Microsoft.EntityFrameworkCore.DbSet`1" /> properties on your derived context. The resulting model may be cached
/// and re-used for subsequent instances of your derived context.
/// </summary>
/// <remarks>
/// If a model is explicitly set on the options for this context (via <see cref="M:Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.UseModel(Microsoft.EntityFrameworkCore.Metadata.IModel)" />)
/// then this method will not be run.
/// </remarks>
/// <param name="modelBuilder">
/// The builder being used to construct the model for this context. Databases (and other extensions) typically
/// define extension methods on this object that allow you to configure aspects of the model that are specific
/// to a given database.
/// </param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
OnModelCreatingImpl(modelBuilder);

modelBuilder.HasDefaultSchema("dbo");

modelBuilder.Entity<global::SureImpact.Data.Framework.TestData>()
.ToTable("TestDatas")
.HasKey(t => t.Id);
modelBuilder.Entity<global::SureImpact.Data.Framework.TestData>()
.Property(t => t.TestString)
.HasMaxLength(200)
.IsRequired();
modelBuilder.Entity<global::SureImpact.Data.Framework.TestData>().HasIndex(t => t.TestString)
.IsUnique();
modelBuilder.Entity<global::SureImpact.Data.Framework.TestData>()
.Property(t => t.Id)
.ValueGeneratedOnAdd()
.IsRequired();

modelBuilder.Entity<global::SureImpact.Data.Framework.TestView>()
.ToTable("TestViews");
modelBuilder.Entity<global::SureImpact.Data.Framework.TestView>()
.Property(t => t.TestString)
.HasMaxLength(200)
.IsRequired();
modelBuilder.Entity<global::SureImpact.Data.Framework.TestView>().HasIndex(t => t.TestString)
.IsUnique();

OnModelCreatedImpl(modelBuilder);
}
}
}
19 changes: 18 additions & 1 deletion src/Testing/Sandbox/Sandbox_EFCore/EFModel1.efmodel
@@ -1,5 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<modelRoot xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="3.0.6.3" Id="cba47279-0950-4257-bb2c-e4d5e72a52a4" entityContainerName="AppDbContext" namespace="SureImpact.Data.Framework" connectionString="Data Source=.\sqlexpress;Initial Catalog=Test;Integrated Security=True" automaticMigrationsEnabled="false" inheritanceStrategy="TablePerType" transformOnSave="false" showCascadeDeletes="true" databaseType="None" warnOnMissingDocumentation="false" entityFrameworkPackageVersion="5.0.Latest" exposeForeignKeys="false" showForeignKeyPropertyNames="false" propertyAccessModeDefault="Field" generateDbContextFactory="false" showInterfaceIndicators="false" xmlns="http://schemas.microsoft.com/dsltools/EFModel">
<modelRoot xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="3.0.7.1" Id="cba47279-0950-4257-bb2c-e4d5e72a52a4" entityContainerName="AppDbContext" namespace="SureImpact.Data.Framework" connectionString="Data Source=.\sqlexpress;Initial Catalog=Test;Integrated Security=True" automaticMigrationsEnabled="false" inheritanceStrategy="TablePerType" transformOnSave="false" showCascadeDeletes="true" databaseType="None" warnOnMissingDocumentation="false" entityFrameworkPackageVersion="5.0.Latest" exposeForeignKeys="false" showForeignKeyPropertyNames="false" propertyAccessModeDefault="Field" generateDbContextFactory="false" showInterfaceIndicators="false" xmlns="http://schemas.microsoft.com/dsltools/EFModel">
<classes>
<modelRootHasClasses Id="9e44b76d-3a4a-491f-bba3-38c96860c916">
<modelClass Id="a25e7ae0-335c-4117-906f-dd0f9cb07de8" tableName="TestViews" databaseSchema="dbo" namespace="SureImpact.Data.Framework" dbSetName="TestViews" name="TestView" outputDirectory="" autoPropertyDefault="true" excludeFromMigrations="false" isDatabaseView="true" viewName="TestView">
<attributes>
<modelAttribute Id="02278efe-ffd5-4aea-82d5-aa931831c5be" required="true" maxLength="200" indexed="true" indexedUnique="true" stringType="None" summary="Test string" name="TestString" autoProperty="true" minLength="0" columnName="TestString" columnType="default" implementNotify="false" isForeignKeyFor="00000000-0000-0000-0000-000000000000" backingFieldName="_testString" databaseCollation="default" propertyAccessMode="Field" />
</attributes>
</modelClass>
</modelRootHasClasses>
<modelRootHasClasses Id="7b894447-1df8-44d8-9a77-ca4ff399acb4">
<modelClass Id="3595f392-f07d-4020-9a1b-01f708cfe94b" tableName="TestDatas" databaseSchema="dbo" namespace="SureImpact.Data.Framework" dbSetName="TestDatas" name="TestData" outputDirectory="" autoPropertyDefault="true" excludeFromMigrations="false" viewName="TestView">
<attributes>
<modelAttribute Id="d141a9fd-44a2-4d14-999a-0722bd81bb9a" required="true" maxLength="200" indexed="true" indexedUnique="true" stringType="None" summary="Test string" name="TestString" autoProperty="true" minLength="0" columnName="TestString" columnType="default" implementNotify="false" isForeignKeyFor="00000000-0000-0000-0000-000000000000" backingFieldName="_testString" databaseCollation="default" propertyAccessMode="Field" />
<modelAttribute Id="34c7c5cc-63f1-4d48-b9df-f4e4d1a58925" type="Int64" isIdentity="true" required="true" maxLength="" indexed="true" indexedUnique="true" stringType="None" identityType="AutoGenerated" summary="Unique identifier" name="Id" autoProperty="true" minLength="0" columnName="Id" columnType="default" implementNotify="false" isForeignKeyFor="00000000-0000-0000-0000-000000000000" backingFieldName="_id" databaseCollation="default" propertyAccessMode="Field" />
</attributes>
</modelClass>
</modelRootHasClasses>
</classes>
<diagrams>
<modelRootHasModelDiagrams Id="42257650-0306-49f1-bea5-c685df6ef205">
<modelDiagramData name="EFModel1" />
Expand Down
20 changes: 20 additions & 0 deletions src/Testing/Sandbox/Sandbox_EFCore/EFModel1.efmodel.diagramx
Expand Up @@ -2,5 +2,25 @@
<eFModelDiagrams>
<eFModelDiagram dslVersion="1.0.0.0" Id="20ccab71-9ece-4c09-82ec-3b299beba94e" type="Sawczyn.EFDesigner.EFModel.EFModelDiagram" absoluteBounds="0, 0, 11, 8.5" name="EFModel1">
<modelRootMoniker Id="cba47279-0950-4257-bb2c-e4d5e72a52a4" />
<nestedChildShapes>
<classShape Id="c9e45787-7ed8-41a3-8578-53c98dbeea37" absoluteBounds="4.6875, 3.09375, 1.5, 1.3704703776041658" fillColor="0, 122, 204" textColor="White" outlineColor="Black" outlineDashStyle="Solid" outlineThickness="0.01">
<modelClassMoniker Id="a25e7ae0-335c-4117-906f-dd0f9cb07de8" />
<relativeChildShapes />
<nestedChildShapes>
<elementListCompartment Id="2a5b2843-d3c7-42b8-88f5-febff5ec13d4" absoluteBounds="4.7025, 3.40375, 1.4700000000000002, 0.44169108072916657" name="AttributesCompartment" titleTextColor="Black" itemTextColor="Black" />
<elementListCompartment Id="7bd1056b-acfe-4f84-91c0-033257f0ab11" absoluteBounds="4.7025, 3.8554410807291664, 1.4700000000000002, 0.2493896484375" name="AssociationsCompartment" titleTextColor="Black" itemTextColor="Black" />
<elementListCompartment Id="241f974e-e15c-4211-a6a0-f2588f32b8e8" absoluteBounds="4.7025, 4.1148307291666661, 1.4700000000000002, 0.2493896484375" name="SourcesCompartment" titleTextColor="Black" itemTextColor="Black" />
</nestedChildShapes>
</classShape>
<classShape Id="c59fa41b-ea35-42ad-86bb-c7e2e78eb165" absoluteBounds="2.5, 0.5, 1.5, 1.5627718098958332" fillColor="0, 122, 204" textColor="White" outlineColor="Black" outlineDashStyle="Solid" outlineThickness="0.01">
<modelClassMoniker Id="3595f392-f07d-4020-9a1b-01f708cfe94b" />
<relativeChildShapes />
<nestedChildShapes>
<elementListCompartment Id="579ce8bf-b6ef-4061-9af2-86cc333c9399" absoluteBounds="2.515, 0.81, 1.4700000000000002, 0.63399251302083326" name="AttributesCompartment" titleTextColor="Black" itemTextColor="Black" />
<elementListCompartment Id="5188df89-a022-4fa5-8ce6-bb132976a10c" absoluteBounds="2.515, 1.4539925130208333, 1.4700000000000002, 0.2493896484375" name="AssociationsCompartment" titleTextColor="Black" itemTextColor="Black" />
<elementListCompartment Id="53f12477-fdd4-4d34-90d5-302158032eca" absoluteBounds="2.515, 1.7133821614583333, 1.4700000000000002, 0.2493896484375" name="SourcesCompartment" titleTextColor="Black" itemTextColor="Black" />
</nestedChildShapes>
</classShape>
</nestedChildShapes>
</eFModelDiagram>
</eFModelDiagrams>
18 changes: 6 additions & 12 deletions src/Testing/Sandbox/Sandbox_EFCore/Sandbox_EFCore.csproj
Expand Up @@ -41,28 +41,22 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppDbContext.generated.cs">
<DependentUpon>EFModel1.tt</DependentUpon>
</Compile>
<Compile Include="Custom\EFModel.cs" />
<Compile Include="EFModel1.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>EFModel1.tt</DependentUpon>
</Compile>
<Compile Include="EFModel1.generated.cs">
<DependentUpon>EFModel1.tt</DependentUpon>
</Compile>
<Compile Include="Entity1.generated.cs">
<DependentUpon>EFModel1.tt</DependentUpon>
</Compile>
<Compile Include="EntityAbstract.generated.cs">
<DependentUpon>EFModel1.tt</DependentUpon>
</Compile>
<Compile Include="EntityImplementation.generated.cs">
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestData.generated.cs">
<DependentUpon>EFModel1.tt</DependentUpon>
</Compile>
<Compile Include="EntityRelated.generated.cs">
<Compile Include="TestView.generated.cs">
<DependentUpon>EFModel1.tt</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
93 changes: 93 additions & 0 deletions src/Testing/Sandbox/Sandbox_EFCore/TestData.generated.cs
@@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
//
// Produced by Entity Framework Visual Editor v3.0.7.1
// Source: https://github.com/msawczyn/EFDesigner
// Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner
// Documentation: https://msawczyn.github.io/EFDesigner/
// License (MIT): https://github.com/msawczyn/EFDesigner/blob/master/LICENSE
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.CompilerServices;

namespace SureImpact.Data.Framework
{
public partial class TestData
{
partial void Init();

/// <summary>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected TestData()
{
Init();
}

/// <summary>
/// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
/// </summary>
public static TestData CreateTestDataUnsafe()
{
return new TestData();
}

/// <summary>
/// Public constructor with required data
/// </summary>
/// <param name="teststring">Test string</param>
public TestData(string teststring)
{
if (string.IsNullOrEmpty(teststring)) throw new ArgumentNullException(nameof(teststring));
this.TestString = teststring;

Init();
}

/// <summary>
/// Static create function (for use in LINQ queries, etc.)
/// </summary>
/// <param name="teststring">Test string</param>
public static TestData Create(string teststring)
{
return new TestData(teststring);
}

/*************************************************************************
* Properties
*************************************************************************/

/// <summary>
/// Indexed, Required, Max length = 200
/// Test string
/// </summary>
[Required]
[MaxLength(200)]
[StringLength(200)]
[System.ComponentModel.Description("Test string")]
public string TestString { get; set; }

/// <summary>
/// Identity, Indexed, Required
/// Unique identifier
/// </summary>
[Key]
[Required]
[System.ComponentModel.Description("Unique identifier")]
public long Id { get; set; }

}
}

0 comments on commit b7ddb0d

Please sign in to comment.