Giter VIP home page Giter VIP logo

msawczyn / efdesigner Goto Github PK

View Code? Open in Web Editor NEW
363.0 18.0 61.0 2.36 GB

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond

License: MIT License

Batchfile 0.07% C# 94.42% Smalltalk 0.17% CSS 0.02% HTML 0.05% JavaScript 0.01% Rich Text Format 2.42% PowerShell 0.06% ASL 2.74% XSLT 0.05%
code-generation code-generator modeling visual-studio visualstudio entity-framework-core entityframework ef6 efcore entity-framework

efdesigner's Introduction

Entity Framework Designer - VS2019 Version

Entity Framework visual design surface and code-first code generation for EF6, EFCore and beyond.

This package is for VS2019. The VS2022 version is available in the EFDesigner2022 project

Model and generate code for both Entity Framework v6.x and Entity Framework Core 2.x, 3.x and 5.

Install with NuGet from the Visual Studio Marketplace

Complete documentation in the project's documentation site

This Visual Studio 2019 extension is the easiest way to add a consistently correct Entity Framework (EF6 or EFCore) model to your project.

It's an opinionated code generator, adding a new file type (.efmodel) that allows for fast, easy and, most importantly, visual design of persistent classes. Inheritance, unidirectional and bidirectional associations are all supported. Enumerations are also included in the visual model, as is the ability to add text blocks to explain potentially arcane parts of your design.

While giving you complete control over how the code is generated you'll be able to create, out of the box, sophisticated, consistent and correct Entity Framework code that can be regenerated when your model changes. And, since the code is written using partial classes, any additions you make to your generated code are retained across subsequent generations. The designer doesn't need to be present to use the code that's generated - it generates standard C#, using the code-first, fluent API - so the tool doesn't become a dependency to your project.

If you are used to the EF visual modeling that comes with Visual Studio, you'll be pretty much at home. The goal was to duplicate at least those features and, in addition, add all the little things that should have been there. Things like:

  • importing entities from C# source, or existing DbContext definitions (including their entities) from compiled EF6 or EFCore assemblies
  • multiple views of your model to highlight important aspects of your design
  • the ability to show and hide parts of the model
  • easy customization of generated output by editing or even replacing the T4 templates
  • entities by default generated as partial classes so the generated code can be easily extended
  • class and enumeration nodes that can be colored to visually group the model
  • different concerns being generated into different subdirectories (entities, enums, dbcontext)
  • string length, index flags, required attributes and other properties being available in the designer

and many other nice-to-have bits.

Code generation is completely customizable via T4 templates. The tool installs templates that target both EF6 and EFCore, and generate both a code-first DbContext class and POCO entity classes. The EF6 template's DbContext code is written to allow consumption in ASP.Net Core in addition to any other project type, so you'll have flexibility in your development.

Note: This tool does not reverse engineer from the database (i.e., "database-first"). Microsoft has provided tools for that, and there are other, well-maintained opensourced projects that provide that functionality as well.

You can read more about how to use the designer in the Documentation site.

Shout out and a big thanks

to for providing free development tools to support this project.

Change Log

3.0.8

  • Autoproperty setting for End1 on association wasn't persisting, so reloading the model lost that change
3.0.7
  • Fixed a number of issues with importing compiled assemblies
  • Fixed coloring of cascade delete associations when flagged on the model (see #291)
  • Fixed missing '$' in generator template that was generating bad code for table schemas (see #289)
  • Restored auto-instantiation of dependent objects in entity constructors (see #287)
  • Added Microsoft.VisualStudio.Modeling.Components.15.0.dll to DslPackage assembly (see #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)
3.0.6
  • Added ability to copy current diagram to clipboard
  • DbContext fix for configuring associations with backing fields
  • Code generation fix for associations with backing fields
3.0.5
  • Fix where parsing EF version numbers should be culture-neutral (see #282)
  • Fixed circular logic flaw in identity properties for database views (see #275)
  • Corrected tracking property access modes from the default to overrides in entity attributes
3.0.4
  • Added context menu choice to visually align node elements on diagrams.
  • Fix for detecting correct EF version when anything with "Latest" in it is configured (see #266)
  • Fix to generate correct initial value code for decimal properties (see #268)
  • Fix for constructor code generation in 1-N unidirectional associations (see #263)
  • Removed addition of default objects in constructors for required associations for all EF versions (see #271)
3.0.3
  • Added VS UML icon for model file in solution explorer (thanks to https://github.com/dcastenholz for the change)
  • Classes with custom interfaces can now display an indicator with a tooltip indicating the interface type(s). This glyph is enabled/disabled at model level.
  • Added ability to specify that an association should be automatically included in any queries that use it (EFCore5 only). The association connector will appear bolder if at least one end is auto-included.
  • Updated association tooltip to indicate which, if any, end is auto-included
  • Fix to ensure database collation overrides don't get applied to the wrong column types
  • Fix to allow 1..1 association to owned types in EFCore5 (see #252)
  • Fix to calculate EF version number correctly when "Latest" was specified in designer (see #254)
  • Fix to generate correct DeleteBehavior enum values in EFCore < v3 (see #257)
  • Removed INotifyPropertyChanged option from designer. Implementers wanting this interface can add it to a partial class file as any other interface, as there's really nothing special about it.
  • Generated code now honors the ExcludeFromMigration setting for a class
3.0.2
  • Added setting on designer surface to set visibility defaults for entity default constructors, and overrides for that setting on the entities
  • Added public bool ModelAttribute.IsForeignKeyProperty for use by developers doing custom code generation from the model
  • Added option for turning off DbSet and table name pluralization (see #246)
  • Added option for how to name foreign key shadow properties - either with or without underscores (see #250)
  • Added option to generate DbContextFactory class, for use in context pooling. Asking for DbContext factory method generation disables generating OnCreating method, since they don't play well together.
  • Changed property editor for custom attributes to be multiline, to ease editing (see #251)
  • Fixes for code generation of new EFCore5 database collation options
  • Fixed condition where sometimes generated code in entity default constructors would create infinitely recursive calls
  • Stopped escaping standard XML comment tags in summary and description fields (see #248)
  • Due to the new seeding needs in EFCore5, setters for identity properties are now public even if set to be auto-generated
3.0.1
  • Added [Description] attribute (to classes, properties, enums and enum values where summary was non-blank) to facilitate tooling use
  • Fixed an issue where EFCore5 code was generating cascade delete commands in the wrong place (see #243)
  • Editing class properties and enum values as text now retains properties that aren't available in the text syntax (see #242)
3.0
  • Now supports EFCore5.X
    • Added System.Net.IPAddress and System.Net.NetworkInformation.PhysicalAddress to the list of available property types
    • Added ability to specify both default database collation and a collation override at the property level
    • Many-to-many bidirectional associations are now allowed
    • Any property type can now be used as an identity
    • Can now customize backing field names for non-AutoProperty properties
    • Properties with backing fields (i.e., non-AutoProperty properties) can now choose how EF will read/write those values (see https://docs.microsoft.com/en-us/ef/core/modeling/backing-field).
    • Added support for keyless entity types created by defining queries
    • Added support for keyless entity types coming from database views
  • Default code generation type is now the latest version of EFCore (currently, 5.0)
  • Added ability to globally add and remove exposed foreign key properties to all modeled entities (via menu command) (see https://github.com/msawczyn/EFDesigner/issues/223)
  • Added ability to choose to place newly imported model elements on the diagram where they were dropped. Caution: this can be EXTREMELY slow for large imports. (see #225)
  • Added composition and aggregation indicators to association connectors
  • Fixed inability to paste enumerations using diagram copy/paste
  • Changing an identity property's type now changes the type of any defined foreign-key properties pointing to that identity property
  • Title text color didn't always change when class/enum fill color changed in the diagram
  • Selecting tabs or spaces for indentation in generated code has been moved to a property on the designer surface.
  • Added ModelRoot.IsEFCore5Plus convenience property. It can be used in custom T4 edits
  • Possibly breaking changes:
    • T4 template structure has been changed drastically to simplify managing code generation for the various EF versions. If customized T4 templates have been added to a project, they'll still work, but enhancements will continue to be made only to the new, more object-oriented, T4 structure. Updating the model's .tt file to use the new template structure is quite simple; details will be in the documentation at https://msawczyn.github.io/EFDesigner/Customizing.html
2.0.5.7
  • Added ability to select tabs or spaces for indentation in generated code (Tools/Options/Entity Framework Visual Editor/Visual Editor Options) (See #221)
  • Fixed an issue with changing visual grid size on design surface.
2.0.5.6
  • The project item templates for the model file had wandered away. They're back again. (See #216)
  • Fixed a problem with existing models where class-level "AutoProperty: false" caused bad code generation. (See #215)
2.0.5.5
  • Fix: Foreign key crashes when reference is on the derived table (See #212)
  • Fixed a edge condition where an error would be thrown when deleting an association
2.0.5.3
  • Provide option to save diagrams as uncompressed XML to facilitate version control (in Tools/Options/Entity Framework Visual Editor)
  • Enhanced error reporting for assembly import errors
  • Assembly import can now process assemblies with more than one DbContext class
  • Cleaned up some ambiguities in how copy/paste was handled with multiple diagrams
  • Performance improvements
2.0.4.1
  • Added ability to hide foreign key property names on association connectors in diagrams
  • Attribute glyphs (except for Warning glyphs) in diagrams are now reflected in Model Explorer
  • Sped up reverse engineering a compiled assembly. As a consequence, the diagram is no longer updated when the assembly is imported (but that tended to ruin the diagram anyway)
  • Fix: Self-associations didn't appear when existing class is added to new diagram from the Model Explorer
  • Fix: Diagram no longer loses focus after its saved
  • Fix: Errors when copy/paste between diagrams in same model
  • Fix: Generalization links weren't being handled property when reverse engineering a compiled assembly
  • Fix: Under certain circumstances, declared foreign keys could erroneously be created for EF6 1-1 relationships. EF6 doesn't support this.
  • Fix: ensure glyphs in association compartments are visible
  • Fix: overly-aggressive pruning in foreign keys
2.0.3
  • Added ability to hide foreign key property names on association connectors in diagrams
  • Attribute glyphs (except for Warning glyphs) in diagrams are now reflected in Model Explorer
  • Fix: Self-associations didn't appear when existing class is added to new diagram from the Model Explorer
  • Fix: Diagram no longer loses focus after its saved
  • Fix: Errors when copy/paste between diagrams in same model
2.02
  • Added count of elements in model explorer tree
  • Added ability to search the model explorer for class and attribute names
  • Comments can also be hidden like classes and enumerations
  • Fix: Changing String Column Name Clears Max Length Property (See #173)
  • Fix: Dropping external files creates elements but not shapes on diagram (See #150)
  • Fix: VS Crash (See #177)
  • Fix: Attributes only show up on diagram where they were added (See #179)
  • Fix: EFDesigner 2.0.1 won't create entities in the efmodel for existing poco .cs files (See #182)
2.0.0
  • Dropped support for Visual Studio 2017; was getting to be too much to keep the tool viable for that Visual Studio version.
  • It's now possible to have multiple diagrams for the same model, each showing a different view and synchronized as the model changes. Perfect for helping to understand large models.
  • Added ability to specify foreign key properties (See #55)
  • Foreign key properties have a unique glyph so they can be easily picked out of the crowd
  • Foreign key properties that are primary keys also have a unique but different glyph
  • Completely restructured assembly parsers; they now cleanly handle all valid combinations of EF6/EFCore2/EFCore3 and .NETCore2/.NETCore3/.NETFramework
  • Modified assembly parsers to find declared foreign keys and add them to the model appropriately
  • Added options dialog (Tools/Options/Entity Framework Visual Editor)
  • Added use of GraphViz for model layout (if installed and path is added to "Tools/Options/Entity Framework Visual Editor")
  • Added switch to disable generation of classes and enumerations for those cases where they are coming from different assemblies but need to be in the model to avoid errors
  • Added visual indicator on classes and enumerations where code generation is disabled
  • Added ability to override the base class of the generated DbContext to be something other than "DbContext"
  • Join tables in many-to-many associations can now have custom names (EF6 only, until EFCore supports many-to-many cardinalities)
  • Removing an enumeration removes all entity properties that use that enumeration, after displaying a warning.
  • Designer has optional visual grid with color, size and snap-to-grid options available
  • Renamed toolbox category to "EF Model Diagrams"
  • Enhanced display of model elements in the Visual Studio property window's object list
  • Removed MSAGL layouts. No one understood them anyway.
  • Removed tool automatically installing NuGet packages. Too volatile.
  • Fix: OutputDirectory lost on reload (See #144)
  • Fix: Unidirectional Many-to-One Association missing Required (See #145)
  • Fix: Couldn't delete property initial value for Enum values (See #148)
  • Fix: Support for Empty / blank "File Name Marker" (See #149)
  • Fix: Now escaping XML comment text properly
  • Fix: Issue with GeographyPoint: System.Data.Entities.Spatial not found for .Net Core 3.1 (See #159)
  • Fix: HasDefaultSchema doesn't work with MySql (See #160)
1.3.0.12
  • Last version supporting Visual Studio 2017
  • Fix: Compilation Error after Upgrading to v1.3.0.11 (See #129)
  • Fix: Designer Drag/Drop Interpreter fails (See #128 and #132)
  • Fix: Enumerations generated into entity directory rather than enumeration directory
1.3.0.11
  • Removed default checks in constructors for scalars
1.3.0.10
  • Build for VS2017 support
1.3.0.9
  • Fix: backing fields caused duplicate database columns (See #101)
  • Fix: bad merge broke MaxLength and MinLength properties in entity string properties (See #103)
  • Fix: attribute parser ("edit as code" feature) didn't handle enumeration initial values well; it does now (See #104)
  • Fix: showing cascade delete in the designer worked inconsistently (See #108)
  • Fix: drag and drop developed regressions (See #112 and #114)
  • Fix: undo threw null reference errors when undoing drag and drop from code files (See #113)
  • Fix: 'KeyBuilder' does not contain definition for 'Ignore' in EF Core (See #115)
  • Fix: Identity properties ignore Setter Visibility setting (See #118)
  • Changed string MaxLength to differentiate between undefined and max length (See #118)
  • Restructured display of namespaces and output directories in the designer's property window
  • Removed visibility option for setters of automatic identity properties.
1.3.0.7
  • Fix: bad merge broke MaxLength and MinLength properties in entity string properties (See #103)
  • Fix: backing fields caused duplicate database columns (See #101)
1.3.0.6
  • Added a model fixup for when user doesn't use full enumeration name for a property's initial value in an entity (See #82)
  • To more fully support DDD models, added a toggle for persisting either the property or its backing field (if not an autoproperty) for EFCore
  • Can now override the NotifyPropertyChanged value for an entity on a per-property and per-association basis
  • Fix: Removed stray quote marks in default values for string properties (See #86)
  • Fix: Minimum string length was ignored when setting properties via text edit (See #86)
  • Fix: Required string identity property is not present in the constructor (See #93)
  • Fix: Some issues with owned entities in EFCore
  • Fix: If NotifyPropertyChanged is active, wrong Output is generated (See #97)
  • For folks wanting to read and/or modify the source for this tool, added a readme on how to deal with tracking properties
1.3.0.4
  • Fixed problematic code generation in constructors for classes having 1..1 associations (See #74)
  • Fixed problem where database was always generating identity values, regardless of setting in the model (See #79)
  • Fixed errors when creating nested project folders (See #77)
  • Fixed cascade delete errors in EFCore when overriding cascade behavior (See #76)
  • Added more information in headers for generated code (tool version, URLs, license info)
1.3.0.2
  • Fixed error found in some VS2017 installations preventing running due to dependency problems
1.3.0.1
  • Enhanced source code drag/drop to handle bidirectional associations and enumerations better.
  • Can now import assemblies containing DbContext classes. Dropping a compiled assembly onto the design surface will attempt to process and merge it into the design.
  • Added ability to merge two unidirectional associations into one bidirectional association (via context menu action)
  • Added ability to split a bidirectional association to two unidirectional associations (via context menu action)
  • Added Microsoft Automatic Graph Layout, giving the user the ability to choose the diagram's auto-layout strategy
Earlier

1.2.7.2

  • Added additional types of UInt16, UInt32, UInt64 and SByte to property type list
  • Added the ability to use a modeled enumeration, if it has a proper backing type, as an entity identifier
  • Added DateTime.UtcNow as a valid initial value for a DateTime property
  • Fix: "One-to-one relation in EFCore" (See #71)
  • Remove default DbContext constructor in EFCore to allow support for AddDbContextPool calls in ConfigureServices (See #72)

1.2.7.1

  • Works with Visual Studio 2019 - mostly (see Known Issues, above)
  • Better formatting for XML comment docs
  • Added autoproperty toggle for association ends, allowing for implementation of partial methods to examine and/or override association getting and setting
  • Removed experimental method added in 1.2.6.22 for generation of orphan association cleanup in EF6. The experiment failed :-(
  • Documentation enhancements
  • Change in generated code to eliminate name clashes in certain circumstances (See #48)
  • Fix: Removed duplicate indices being created for key fields
  • Fix: "Setting different value than default produces duplicated HasColumnType call in EF Core" (See #58). Thanks to tdabek (https://github.com/tdabek) for the PR!
  • Fix: "Defining ColumnType causes error in generated DBContext" (See #64)
  • Fix: "EFCore indexed column not generated and support for multi column indexing" (See #62)
  • Fix: "One-to-one seems to generate incorrect code" (See #60)
  • Fix: "Error generating column type" (See #58)

1.2.6.25

  • Fix for duplicate associations when Implement Notify is true

1.2.6.24

  • Fix for join table schema generation in certain scenarios (EF6)
  • Fix for regression error producing code gen errors in EFCore navigation properties

1.2.6.23

  • Fix for designer item not showing in Add Items dialog

1.2.6.22

  • [NEW] Added code in EF6 templates to generate orphan cleanup (experimental)
  • Fix for 1..1 and 0-1..0-1 associations in EF Core generated code
  • Entity constructor parameters normalized to help in JSON serialization/deserialization

1.2.6.21

  • Generation of column type overrides now generates valid override code in OnModelCreating
  • DbSet properties in DbContext generate as virtual to facilitate mocking

1.2.6.20

  • Fixed code generation issue where class and enum directory overrides were being ignored (See #36)
  • Fixed a problem that caused a hard crash when certain model properties were changed under certain conditions (See #38)
  • Removed visibility of source and target roles for all but 1-1 and 0..1-0..1 associations; they can't be changed anyway (See #40)
  • [NEW] Added Display Text property to generate [Display(Name="")] for attributes, enum values and navigation properties
  • [NEW] Added ability to specify custom attributes for classes, attributes, enums, enum values and navigation properties

1.2.6.18

  • Fixed issue #35, Concurrency mode: optimistic auto generated Timestamp property (See #35)
  • Fixed issue #33, Concurrency mode: optimistic (See #33)
  • [NEW] Added the base class as a property in the property editor to allow for easily adding/removing inheritance relationships for multiple classes

1.2.6.13

  • Bugfix to remove unnecessary permission requests to push attributes down when deleting leaf nodes in an inheritance tree
  • Fix to workaround Visual Studio pulling in the wrong System.Net.Http reference. (See https://developercommunity.visualstudio.com/content/problem/296293/vs2017-1575-ignores-the-hintpath-and-take-the-syst.html)
  • Add EFModel.xsd to Visual Studio schema cache in order to avoid editor warnings for missing schema
  • Fixed template issue for non-English-language systems (where Microsoft Pluralization Service is unavailable)
  • Added compartment for association sources so Bidirectional associations would show up

1.2.6.11

  • Tweak to force association end roles to be correct when roles or multiplicities change
  • Attribute elements' "String Properties" don't appear unless the attribute is a string
  • Attribute elements' "Indexed Unique" property doesn't appear unless the attribute has "Indexed" equal to "True"
  • Fixed background color on attribute glyph in model explorer
  • Fixed foreground color on enum value glyph on design surface
  • Hid comments in model explorer because they just cluttered up the tree.
  • [NEW] Associations now show up in their own compartment in a class on the design surface. Note that this changes the height of your elements, so the first time opening a model you may have to tweak your esthetics a bit.
  • [NEW] Double-clicking a class or enum on the designer opens the generated code file, if it exists. If it doesn't exist, you're asked if you'd like to generate the model then, if you do, it tries again.
  • Known issue: EFCore projects won't ask to generate the code if they can't open the file; they just fail silently.

1.2.6.7

  • An entity's concurrency token property is no longer a required parameter in its constructor (#24)
  • Simplified cascade delete settings in property editor for associations
  • Fixed bad code generation in EFCore for cascade delete overrides (#22)
  • Missing files when generating code for .NET Core projects fixed
  • Tightened up and swatted some bugs in INotifyPropertyChanged handling. Added documentation to doc site for this feature (following up on #23)
  • Ensured multiline editing was available in property window for those properties that made sense

1.2.6.6

  • [NEW] Deleting a generalization or superclass gives the choice of pushing attributes and associations down to the former child class(es)

1.2.6.5

  • Comment elements now wrap the text
  • Multiline editor available in property window for element comment descriptions and Comment element text
  • Xml format changed for .efmodel file - can't be loaded by any version < 1.2.6.3
  • Support for automatic migration to new model xml formats

1.2.6.2

  • Added XML docs to DbContext, DatabaseInitializer and DbMigrationsConfiguration
  • [NEW] Enabled drag and drop reordering of enum values and class properties
  • Gave some color to the enum value glyph in the model explorer - it was so boring!
  • [NEW] Class properties and enum values with warnings now show a warning icon on the design surface
  • [NEW] Design surface has a property to turn on or off the display of the warning icons
  • Recategorized a few "Misc" properties on the design surface

1.2.5.1

1.2.5.0

1.2.4.0

  • Retargeted immediate error and warning messages to Visual Studio output window rather than error window so they could be cleared
  • Added drag validation to Generalization (inheritance) tool
  • Automatically propagate enum name and value name changes to classes that use them

1.2.3.3

  • Reverted the selection of the node in the model explorer when an element is selected in the diagram. Was causing bad user experience.
  • Fix for bad code generation when a class has multiple properties that each have an darabase index specified.

1.2.3.0

1.2.2.0

  • Fix issue with association role end changing without the other side autoatically changing
  • Fix issue with deleting a highlighted element throwing an error when trying to save the file
  • Fixed code generation for dependent classes
  • [NEW] Designer now automatically saves before generating code

1.2.1.0

  • Bug fix for inheritance strategy automatically changing to table-per-hierarchy if targeting EF Core
  • Updated a few warning and error messages to make them more meaningful
  • Fixes for how dependent types work
  • Remove stale error and warnings prior to save (still a few left hanging around that need looked at)
  • Fixed a few null reference errors

1.2.0.0

  • New Features
    • Roslyn-based code analysis now allows dragging C# files onto the design surface to add or update classes and enums
    • Can add INotifyPropertyChanged interface and implementation for entities
    • Ability to tag model as a specific EF version (especially useful for EF Core as new capabilities are being added often)
    • Support for dependent (complex/owned) types
    • Option to generate dependent types in a separate directory
    • Output directory overrides for classes and enums
    • On model save, can optionally automatically install EF NuGet packages for the model's EF type and version
    • Context menu action to expand and collapse selected classes and enums
  • Enhancements
    • Added ability to add/edit enum values via text in the same way properties can be added/edited in classes
    • Property grid hides element properties if they're not appropriate for the EF version
    • Inheritance strategy automatically changes to table-per-hierarchy if targeting EF Core
    • Context property Database Type changed to SqlServer Type to better reflect what it does
    • Selecting an element in the Model Explorer highlights it on the diagram

1.1.0.0

  • Bug fixes for exceptions thrown when bad input to model attributes as text
  • [NEW] Added MinLength string property (used in EF6 only as of this writing)
  • Modified attribute parser to accept MinLength
  • [NEW] Added ColumnName property to model attribute
  • [NEW] Added MEF extension capability
  • Added some unit tests
  • Added some documentation updates
  • Changed version to 1.1.0 due to MEF capability

1.0.3.9

  • If no entities and model is using an unsupported inheritance strategy, changing from EF6 to EFCore doesn't give a message, just changes the strategy.
  • [NEW] Added IsFlags attribute (and matching validations and behavior) to Enums
  • NGENed extension assembly

1.0.3.8

  • Fixed project item placement
  • Added change checks to diagram so dirty flag doesn't set when nothing changes

1.0.3.7

  • Emergency bug fixes

1.0.3.6

  • Fixed parser errors when editing model attributes as text
  • Fixed error when auto-generating on save and design surface is not the active window
  • Fixed crash when used on non-English-language systems (where Microsoft Pluralization Service is unavailable)
  • [NEW] Added option to generate warnings if no documentation
  • Standardized warning and error message structure
  • Added ability to choose 'None' DatabaseInitializer type; generates SetInitializer(null)

1.0.3.5

  • Enhanced portability between EF6 an EFCore

1.0.3.4

  • Adds some T4 fixes to make generated code more usable in ASP.NET Core applications.
  • Fix to spurious error when copying/pasting enum elements.
  • [NEW] First release that's available on Visual Studio Marketplace.

1.0.3.3

  • Fix to spurious error when copying/pasting model elements
  • Do not use this release. Fix didn't extend to enum elements. This is fixed in 1.0.3.4.

1.0.3.2

  • Minor bug fix in parsing manually typed attributes.
  • Loosened model file version check to only check major version.

1.0.3.0

  • Enhanced syntax for adding/editing attributes via code
  • Fix for generate-on-save for both Framework and .NET Core projects.

1.0.2.0

  • [NEW] EFCore T4 template now available

1.0.1.0

  • Fix to EF6 T4 for issue where column names in many-to-many association join tables were flipped

1.0.0.0

  • Initial release

efdesigner's People

Contributors

dcastenholz avatar dependabot[bot] avatar falthazar avatar kernelith avatar michael-sawczyn avatar michaelsawczyn-awh avatar msawczyn avatar opzet avatar ruialias avatar tdabek-euvic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

efdesigner's Issues

Cascade delete

Was trying to define a recursive relation. one-to-many from T to T.
When I validate I get no issue but on db creation I get exception saying I should add ON CASCADE DELETE NOACTION...

Looks like the code options on the relation in the editor does something when set to CASCADE but nothing when set to NONE. [EF6] Which IMHO should be the reverse since EF6 cascades by default. Or the generated code should always add a WillCascadeOn() call with true/false without relying on the default.

I do not know the defaults for EF Core..

Setting the relation ends to CASCADE, then passing false , in place of nothing, into generated code allows the db to be created. Am I doing something wrong or missig something?

Version: 1.2.2.1

And kudos for such a nice tool.

Thanks,
D.

InvalidCastException in MultipleOutputHelper.ttinclude

Hi, this is my first time submitting an issue on Github so let me know if I did anything wrong or if I need to provide more information.

I have a model with about 40 entities I've been designing and not sure when the error first showed up. I'm not even sure its really even a problem since I haven't looked over the code yet, but I started a new solution just to test and the error showed after saving the second entity. Didn't resolve after deleting the second entity, so hit ctrl-z unitl it was an empty canvas, and deleted the generated code for those entities and its still there.

Running transformation: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'EnvDTE.ProjectItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0B48100A-473E-433C-AB8F-66B9739AB620}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at Microsoft.VisualStudio.TextTemplating3246E923D3EAE737EADEB8472DF30160C46F1C6A28C09523326DEB23229A387D8DA775DCCD37FC548552E35F5D34C0A8931C74294263E74318F0438421180078.GeneratedTextTransformation.Manager.VSManager.GetCurrentState() in c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\rr1dks0x.21c\TextTemplates\MultipleOutputHelper.ttinclude:line 303
at Microsoft.VisualStudio.TextTemplating3246E923D3EAE737EADEB8472DF30160C46F1C6A28C09523326DEB23229A387D8DA775DCCD37FC548552E35F5D34C0A8931C74294263E74318F0438421180078.GeneratedTextTransformation.Manager.VSManager.ProjectSync(IEnumerable`1 keepFileNames) in c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\rr1dks0x.21c\TextTemplates\MultipleOutputHelper.ttinclude:line 246
at Microsoft.VisualStudio.TextTemplating3246E923D3EAE737EADEB8472DF30160C46F1C6A28C09523326DEB23229A387D8DA775DCCD37FC548552E35F5D34C0A8931C74294263E74318F0438421180078.GeneratedTextTransformation.Manager.VSManager.Process(Boolean split) in c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\rr1dks0x.21c\TextTemplates\MultipleOutputHelper.ttinclude:line 174
at Microsoft.VisualStudio.TextTemplating3246E923D3EAE737EADEB8472DF30160C46F1C6A28C09523326DEB23229A387D8DA775DCCD37FC548552E35F5D34C0A8931C74294263E74318F0438421180078.GeneratedTextTransformation.TransformText() in C:\Users\vaultboy\source\repos\LoadoutBuilder\LoadoutBuilderClasses\LoadoutBuilderModel.tt:line 50 Miscellaneous Files c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\rr1dks0x.21c\TextTemplates\MultipleOutputHelper.ttinclude 303

Generate diagram from DB

Can this be used to generate the initial diagram from an existing database providing a CNS?

Great project!

Unique index not generated

Wanted a unique index on a string column[25], so selected both Indexed and unique index to true.
Index is created but the unique info seems to be ignored.

D.

A couple of questions

Hi. great work.

1 - is biderectional relationships many to many ? if that's the case, how to use it, can't get it to work.

2 - in inheritance, what's the descriminator field ? it does not seem to mention it anywhere ?

Generate Enum attribute

How I can generate enum with Annotation [Display]? eg:

public enum Salary
{
[Display(Name="Paid Monthly")]
PaidMonthly = 1,
PaidYearly = 2
}

Recognize "Id" as primary key on import

I started trying this out today by importing a set of EF Core classes.

One thing that I had to do was to go through 50+ classes and mark the Id field as primary key.
EF Core automagically recognizes Id as being the primary key, so that doesn't need to be tagged by an attribute.
It would be practical if you could set an option to make EFDesigner do the same.

Abstract/inherited/TPC =code still there for abstract class

Context: trying to see how to adapt usage of the tool for use with existing stuff (base classes provided by a internal framework)...

Created a model with an abstrat class AuditEntity that has Id/ChangedOn/ChangedBy properties.
Have classes in my model inherit from this.
Chose TPC for inheritance mapping...

  1. Yet there seems to be a dbset for this abstract class [I did not expect this] .

  2. When I create an new E_Application and do savechanges(), EF apparently tries to cast my E_application to an AuditEntity and fails.

I do not really know if the two symptoms are linked or separate issues or just wrong expectations/modeling by me...

image
image
image
image

Enhancement: Default Default Constructor Visibility

The title is not a typo. I would like a new setting in the designer for Entity Model settings that will set the default visibility for the default constructor for all entities in the model. OData requires a public default constructor for POST operations. The second half of the feature would be in the code generation side where you could have something like:

public void WriteConstructor(ModelClass modelClass)
{
	Output("partial void Init();");
	NL();

	/***********************************************************************/
	// Default constructor
	/***********************************************************************/
			
	bool hasDefaultVisibility = GetDefaultVisibility() == null;
	bool hasRequiredParameters = GetRequiredParameters(modelClass, false).Any();
	string visibility = !hasDefaultVisibility && (hasRequiredParameters || modelClass.IsAbstract) ? "protected" :  GetDefaultVisibility();
...

Thanks for such an awesome effort and product.

Namespace collision in generated code

I think that it is common for developers to want to name an entity with the same name as part of the project namespace. Ex: I am currently working on a press release application. The project name is PressRelease. My root namespace is PressRelease as well. It is desirable to have an entity named PressRelease, but the generated code will then have numerous errors due to the collision. In my case, ModelClass.FullName for my Stage enum returns "PressRelease.EntityFramework.Model.Stage". In a number of places, this collides with the PressRelease entity name. If ModelClass.FullName could return "global::PressRelease.EntityFramework.Model.Stage" instead, it would avoid the collision.

I was almost able to work around the issue by changing the transform code, but I ran into ModelAttribute.FQPrimitiveType which can return int, bool, string, etc. in addition to my fully qualified class name. In C#, global::int is invalid. Inside FQPrimitiveType is the line: return modelEnum.FullName;, so fixing ModelClass.FullName should work. I realize that there is an argument to be made that says: "Don't do that!", but I believe that this would be a nice feature.

Output directories cannot be changed anymore?

Having an issue with latest version (updated yesterday in my VS2017- 15.8.9):
Cannot modify output directories in the properties window:
image
The fields seem to be read-only and the Combo shows Properties but I cannot change the values....
Is this just me?

Any idea?

Strange Issue - Generated code references an entity that is NOT referenced in the diagram

I am running into a very string issue. I have an EF diagram with out 14 entities, some with relationships and some without. There is one entity that no matter what I do it always is generated with a relationship to another entity that is not showing the designer (this includes even removing it and recreating it).

What can I do to track down what is causing this?

Using

  • Visual Studio 2017
  • .NET Core 2.1 project
  • Windows 10 x64

WillCascadeOnDelete not working with EF Core

Hi
When I define relations between entities and set End 1 on delete resp. End 2 on delete to Cascade or None the EFDesigner creates a .WillCascadeOnDelete(true/false). This did not compile on my system. AFIK WillCascadeOnDelete does not exist for EF core (it does in EF6) and OnDelete(DeleteBehavior) has to be used for EF Core.

Replacing the code to generate WillCascadeOnDelete for the for undirectionalassociations with

switch(association.SourceDeleteAction) {
  case DeleteAction.Default:
    //Nothing to do
    break;
  case DeleteAction.Cascade:
    segments.Add("OnDelete(DeleteBehavior.Cascade)");
    break;
  case DeleteAction.None:
    segments.Add("OnDelete(DeleteBehavior.Restrict)");
    break;
}

and for the bidirectionalassociations with

switch(association.SourceDeleteAction) {
  case DeleteAction.Default:
    //Nothing to do
    break;
  case DeleteAction.Cascade:
    segments.Add("OnDelete(DeleteBehavior.Cascade)");
    break;
  case DeleteAction.None:
    segments.Add("OnDelete(DeleteBehavior.Restrict)");
    break;
}

in the EFCoreDesigner.ttinclude seems to fix the problem. Not sure if this would be valid for all use cases.

Small side note:
I'm not sure if I got this right, but for Bidirectionalassociations the docu on End 1 on delete resp. End 2 on delete says How to handle objects on this end if the object on the other end is deleted. However the T4 files for EF core, seem to handle this more like How to handle objects on the other end if the object on this end is deleted.

Integration w/ Owin or Asp Identity

I did read the excerpt detailing that this is not meant to import existing models, and that makes perfect sense.

But configuring asp.net and owin is a significant undertaking, so I'm curious as to an alternative to use with this system?

Perhaps an "interface" between the two, like a table with nothing but foreign keys for UserId, Group, Role, etc, as a layer on top of owin, with which my application-models designed in EFDesigner would interact?
I'd still have to customize the linkages manually in the code, so the model wouldn't perfectly reflect (visually speaking) what is actually taking place.. Adds a bit of overhead too. But maybe that's the answer?

Just curious if anyone has stepped through similar and has any suggestions. Thank you!

Optimized NotifyPropertyChanged support

The current T4 files are generating code that calls OnPropertyChanged whenever the setter of a property is called (even if the value doesnt change). According to the example in How to: Implement the INotifyPropertyChanged Interface OnPropertyChanged is only called when there is a actual change of the value (also my personal preference since it avoids unecessary events).

I'm now using a modifed EFDesigner.ttinclude in my project which generates the following code for the properties:

      #region Property Name of type string
      [Required]
      protected string _Name;

      /// <summary>
      /// Required, Min length = 250
      /// </summary>
      public string Name
      {
         get {return _Name;}
         set {if (_Name != value) {string oldName=_Name; NameChanging(oldName, value);  _Name = value;OnPropertyChanged(nameof(Name)); NameChanged(oldName, value);}}
      }
      partial void NameChanging(string oldName, string newName);
      partial void NameChanged(string oldName, string newName);
      #endregion

Below is the modified method in the modified EFDesigner.ttinclude which I have included in my project. I has the improved OnPropertyChanged handling and it also excludes the ConccurencyToken from calling OnPropertyChanged.

void WritePersistentProperties(ModelClass modelClass)
{
   if (!modelClass.Attributes.Any(x => x.Persistent))
      return;

   Output("// Persistent properties");
   List<string> segments = new List<string>();
   NL();

   foreach (ModelAttribute modelAttribute in modelClass.Attributes.Where(x => x.Persistent))
   {
      string nullable = IsNullable(modelAttribute) ? "?" : "";

      Output($"#region {(modelAttribute.IsConcurrencyToken?"ConcurrencyToken":"Property")} {modelAttribute.Name} of type {modelAttribute.FQPrimitiveType}{nullable}");
      
	  segments.Clear();

      if (modelAttribute.IsIdentity)
         segments.Add("Identity");
      if (modelAttribute.Required || modelAttribute.IsIdentity)
         segments.Add("Required");
      if (modelAttribute.Indexed)
         segments.Add("Indexed");
      if (modelAttribute.MinLength > 0)
         segments.Add($"Min length = {modelAttribute.MinLength}");
      if (modelAttribute.MaxLength > 0)
         segments.Add($"Max length = {modelAttribute.MaxLength}");
      if (!string.IsNullOrEmpty(modelAttribute.InitialValue))
      {
         string quote = modelAttribute.PrimitiveType == "string" ? "\"" : modelAttribute.PrimitiveType == "char" ? "'" : "";
         segments.Add($"Default value = {quote}{FullyQualified(modelClass.ModelRoot, modelAttribute.InitialValue)}{quote}");
      }

     

      if (!modelAttribute.AutoProperty && !modelAttribute.IsConcurrencyToken)
      {
         GenerateClassAnnotations(modelAttribute, "_");
         Output($"protected {modelAttribute.FQPrimitiveType}{nullable} _{modelAttribute.Name};");

         NL();
      }

      if (!string.IsNullOrEmpty(modelAttribute.Summary) || segments.Any())
      {
         Output("/// <summary>");
         if (segments.Any())
            Output($"/// {string.Join(", ", segments)}");
         if (!string.IsNullOrEmpty(modelAttribute.Summary))
            Output("/// {0}", modelAttribute.Summary);
         Output("/// </summary>");
      }
      if (!string.IsNullOrEmpty(modelAttribute.Description))
      {
         Output("/// <remarks>");
         Output("/// {0}", modelAttribute.Description);
         Output("/// </remarks>");
      }

      string setterVisibility = modelAttribute.SetterVisibility == SetterAccessModifier.Protected ? "protected " : modelAttribute.SetterVisibility == SetterAccessModifier.Internal ? "internal " : "";

      if (modelAttribute.AutoProperty || modelAttribute.IsConcurrencyToken)
      {
         GenerateClassAnnotations(modelAttribute);
         Output($"public {modelAttribute.FQPrimitiveType}{nullable} {modelAttribute.Name} {{ get; {setterVisibility}set; }}");
      }
      else
      {

         Output($"public {modelAttribute.FQPrimitiveType}{nullable} {modelAttribute.Name}");
         Output("{");
         Output($"get {{return _{modelAttribute.Name};}}");
         Output($"{setterVisibility}set {{if (_{modelAttribute.Name} != value) {{{modelAttribute.FQPrimitiveType}{nullable} old{modelAttribute.Name}=_{modelAttribute.Name}; {modelAttribute.Name}Changing(old{modelAttribute.Name}, value);  _{modelAttribute.Name} = value;OnPropertyChanged(nameof({modelAttribute.Name})); {modelAttribute.Name}Changed(old{modelAttribute.Name}, value);}}}}");
         Output("}");
      
	     Output($"partial void {modelAttribute.Name}Changing({modelAttribute.FQPrimitiveType}{nullable} old{modelAttribute.Name}, {modelAttribute.FQPrimitiveType}{nullable} new{modelAttribute.Name});");
	     Output($"partial void {modelAttribute.Name}Changed({modelAttribute.FQPrimitiveType}{nullable} old{modelAttribute.Name}, {modelAttribute.FQPrimitiveType}{nullable} new{modelAttribute.Name});");
	  }

	   Output("#endregion");
      NL();
   }

   if (!modelClass.AllAttributes.Any(x => x.IsConcurrencyToken) && 
       (modelClass.Concurrency == ConcurrencyOverride.Optimistic || modelClass.ModelRoot.ConcurrencyDefault == Concurrency.Optimistic))
   {
      Output("/// <summary>");
      Output("/// Concurrency token");
      Output("/// </summary>");
      Output("[Timestamp]");
      Output("public Byte[] Timestamp { get; set; }");
      NL();
   }
}

Error in tt files

image

This is present:
<#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" debug="true"
hostSpecific="true" language="C#" compilerOptions="/langversion:latest"#>

Concurrency token (Timestamp) in constructor parameters

The current implementation of the EFDesigner.ttinclude includes the TimeStamp conccurency token into the parameters of the public constructor with required data and also into the paras of the static Create method.

If I'm not mistaken there is no reaand son why a user should set the conccurency token property and EF core is taking care of this. Therefore I think that the conccurency token property should be excluded from the methods mentioned above.

Remark:
I happpy to share my modified EFDesigner.ttinclude and EFCoreDesigner.ttinclude files, but I at least for now I cant make a pull request, since I just use local copies of these files in my project and have not (yet) forked the EFDesigner project.

Drag-drop issue after update of Designer and VS2017 - Error text good but wrong

Had an issue where I couldn't drag and drop an entity into the designer. Cropped up after updating EF Designer and then VS2017 (to 15.8.6, didn't fix when I updated to 15.8.7).

The error:

Drag drop operation failed with the following error:

Domain object with identity 05ea9a33-a0a8-4940-8a76-d870bb991325 was not found in directory.

A common cause of this exception is an out of date Visual Studio toolbox cache with respect to changes in your domain model. Run "devenv /setup" from the command line to reset this cache.

I tried doing that last bit: Running "devenv/setup" but it doesn't seem to work.
What ended up working was right-clicking the toolbox and selecting "Reset Toolbox", assuming the error is from EF designer maybe the text should be changed to suggest that?

.HasForeignKey in EF core 2.2 does not work

EFDesigner only claims compatibility with "Entity Framework Core 2.0 and 2.1" so maybe this shouldn't be an issue-- however I have been using EF Core 2.2 with EFDesigner release 1.2.6.21 and it was fine. Now with EFDesigner 1.2.6.23 my .generated context has .HasForeignKey in it, my program won't run, (has a problem in OnModelCreating). A quick google suggests also that EF core 2.2 has one or more breaking changes in the fluent API with .HasForeignKey vs EF core 2.1
error1

TPH

Hi it would be nice to have table splits and table per hierarchy support

Foreign Keys not named correctly on code generation

Similar to my last one, sort of.

Same three tables:
image

in the context, it generates:

modelBuilder.Entity<EFCoreDesignTools.JoinSiteInvestigator>()
    .HasOne(x => x.Site)
    .WithOne()
    .HasForeignKey("Site_Id")
    .IsRequired().OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<EFCoreDesignTools.JoinSiteInvestigator>()
    .HasOne(x => x.Investigator)
    .WithOne()
    .HasForeignKey("Investigator_Id")
    .IsRequired().OnDelete(DeleteBehavior.Cascade);

.HasForeignKey("Site_Id") and .HasForeignKey("Investigator_Id") should be generated as "SiteId" and "InvestigatorId" respectively.

I'm not sure if this is an issue with how the relationships are set up, or an issue with the generator?

VS Crash on multiplicity changes

Trying to modify multiplicity of a *->1 relation, VS crashes and restarts...
This happens when trying to open the combo with (expected) other possible values.
Will try to have a simple case and/or vs logs...

Properties generating isUnicode(...) / varchar vs. nvarchar

wanted to get some guidance on best approach for handing ANSI / varchar vs. Unicode / nvarchar for property to column mappings. Best I can determine is to specify [Column(TypeName="varchar")] or [Column(TypeName="nvarchar")] as a custom attribute in the property. Is there a more elegant way to do this?

Feature Request - When renaming tables/columns add annotations so Add-Migration catches the rename

This is probably a very large ask, but I just renamed a table and some fields in the designer. When I went to Add-Migration, it dropped/created a new table instead of renaming.
According to this: https://stackoverflow.com/questions/49799627/rename-a-foreign-key-in-entity-framework-core-without-dropping-data/49802766#49802766

The way to do it is add annotations first, add the migration, and then rename the properties.

Thoughts? It isn't too hard to manually edit the Up method of the migration myself, but I figure if someone does a lot of changes, or has a large database, it could be useful.

MySQL question?

Is it possible to use this extension if database provider is MySQL? Or it is locked to MS SQL only?

Generated code not being output to the override output directory

I created a separate project for the model and created subdirectories (Entities, Enums and Context). Apart from the general object output directory, which is set to Entities, I also set an output directory per entity.

I have an entity called Address and the output directory is set to Entities/PartyAddresses, this directory exists and this was an option inside the combobox.

Upon code generation all entities get generated to the root of the Entities folder.

Concurrency mode: optimistic auto generated Timestamp property

2 separate, yet related bugs:

  1. When Concurrency is set to optimistic, and no property is marked as "Is Concurrency Token", the extension automatically creates a working Timestamp property, but the extension throws an error saying: "Entity1: Should have 1 concurrency properties but has 0".

  2. If you add a property and then mark it as "Is Concurrency Token" = True, the generated property has [Required] on it which causes validation errors on save. The UI does not allow you to change the Required = True setting.

Generate model clasess from code ?

Its possible to generate code from code ?

Could U guide how it is possible ?
I have own metamodel that I put in DB!
And i want to make enterprise ORm genrator

image

generating tables and coulmns are ready, further need generation of class models and ientityconfiguration

Issue using with EF Core

I'm having an issue using it with EF Core.
I created a simple model with 5 tables, but the generated code is making calls that don't exist in Core:
modelBuilder.HasDefaultSchema(..)
EntityTypeBuilder<..>.ToTable(...)
etc.

Entity Framework Version is set to EFCore,
and the Nuget for Microsoft.EntityFrameworkCore(2.0.2)has been added to the class library project, which is .NET Core 2.0 project.

-BCC

Support for complex types

It seems not possible (yet?) to add such cases in the designer.
One can add the first one but validation fails because of a missing Id property in the inheritance chain ... But I do not want one...
class Pos {
double x; double y;
}
Then of course I cannot add a property of type Pos since the type is not recognized...
class Foo {
int Id;
string Name;
Pos Where;
}

Is this something you exclude from the tool or just not here yet?

Thanks,

VS2017: The type initializer ... threw an exception

My VS2017 Community installation is crashing when trying to save a .efmodel
I have an EFcore class library project and added an EFModel, then changed the Entity Framework Version on the .efmodel to EFCore.
VS is already crashing when I try to select the Entity Framework Package Version.
When I ignore that and leave it on "Latest" then VS is crashing when I add an Entity and try to save the .efmodel file.

Following are the error log files. It looks like it doesn't find System.Net.Http

MSBuild_pid-4104_7d49ee7c2a2445fdb59f10eb992466b6.failure.txt
VsProjectFault_2e747c55-d05a-43a3-9498-3281a0f85deb.failure.txt

Additional info:
I had to install English language as it is a Swiss system and I first got an error about the language which is gone now.
Also I have to warnings stating
Cannot find a schema that defines target namespace 'http://schemas.microsoft.com/dsltools/EFModel'

Table with two Primary keys not generated properly in context

Visual Studio 15.7.5
Entity Framework Visual Editor 1.2.2.1
Using EFCore

I have three tables:
Site, Investigator, and a join table to link the two (for many-to-many relationship)
The join table just has InvestigatorId and SiteId properties, and I set them both to Identity = True

The generated context does this:

modelBuilder.Entity<EFCoreDesignTools.JoinSiteInvestigator>()
            .ToTable("JoinSiteInvestigators")
            .HasKey(t => new { t.public Int32 InvestigatorId!, t.public Int32 SiteId! });

Should be:

modelBuilder.Entity<EFCoreDesignTools.JoinSiteInvestigator>()
            .ToTable("JoinSiteInvestigators")
            .HasKey(t => new { t.InvestigatorId, t.SiteId });

OneToMany relation issue since upgrade to 1.2.6.23 with CS0102

Hi,

I today upgraded to version 1.2.6.23 (from 1.2.6.21 I believe). Since then I have an issue with one of my relations which worked fine before.
<unidirectionalAssociation Id="c4bfc1af-ccf6-4dfd-955c-489f6acf160f" sourceMultiplicity="ZeroMany" targetMultiplicity="One" targetPropertyName="Artikel" collectionClass="HashSet" sourceRole="Dependent" targetRole="Principal" foreignKeyLocation="None"> <modelClassMoniker Id="65a01e60-c158-4eaf-a9d9-4f1178f3699f" /> </unidirectionalAssociation>

This generates the definition of Artikel two times:

protected Backend.Data.Artikelstamm Artikel;
and

public Backend.Data.Artikelstamm Artikel { get {
which causes an error CS0102.

Did I do something wrong in the past or is this an issue with the new version? Thanks.

NotImplementedException CultureInfo

Hi, I found a problem with the template. It tries to use my culture to do pluralization, but ended with a not implemented exception.

"Severity Code Description Project File Line Suppression State
Error Running transformation: System.NotImplementedException: The culture 'Czech (Czech Republic)' is not supported. Pluralization is currently only supported for the English language.
at System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(CultureInfo culture)
at Microsoft.VisualStudio.TextTemplatingB1FB882D6FB23F37E071FAC15F790DB3D6CCE1885B7AE52C82326C4BE71A35610CEBC0A8943C91E048871F39722244F659C14ECF1A0B2A1C98B8AC0ACC30204E.GeneratedTextTransformation.WriteDbContextEFCore(ModelRoot modelRoot) in c:\program files (x86)\microsoft visual studio 2017\common7\ide\extensions\ljdqezoc.usq\TextTemplates\EFCoreDesigner.ttinclude:line 134
at Microsoft.VisualStudio.TextTemplatingB1FB882D6FB23F37E071FAC15F790DB3D6CCE1885B7AE52C82326C4BE71A35610CEBC0A8943C91E048871F39722244F659C14ECF1A0B2A1C98B8AC0ACC30204E.GeneratedTextTransformation.GenerateEFCore(Manager manager, ModelRoot modelRoot) in c:\program files (x86)\microsoft visual studio 2017\common7\ide\extensions\ljdqezoc.usq\TextTemplates\EFCoreDesigner.ttinclude:line 42
at Microsoft.VisualStudio.TextTemplatingB1FB882D6FB23F37E071FAC15F790DB3D6CCE1885B7AE52C82326C4BE71A35610CEBC0A8943C91E048871F39722244F659C14ECF1A0B2A1C98B8AC0ACC30204E.GeneratedTextTransformation.TransformText() in C:\Merz\Projekty\Git\CM\Magna.CM\Magna.CM.Database\DatabaseModel.tt:line 44 Miscellaneous Files c:\program files (x86)\microsoft visual studio 2017\common7\ide\extensions\ljdqezoc.usq\TextTemplates\EFCoreDesigner.ttinclude 134
"

Could you please catch the exception and force english pluralization ? Thank you !

Don't create DbSets for many to many linking tables?

It looks like in generally, you don't create DbSets for linking tables in many to many relationships in EF core.

On both the EF core docs: https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
and in "EF Core in Action" by Jon Smith (which I'm currently reading) neither create a DbSet for that table.

Two questions - do you know why that is (neither explain it that I've seen)? And, if there a way to configure EFDesigner to do that?

VS2017 Crash

Created a simple model with 2 entities and a 1 to many association. Selecting either entity and then selecting the Association Sources (or Targets) entry and then clicking on the Properties window dropdown for 'End2 Multiplicity' (which is currently set to 'ZeroMany') causes VS2017 to crash.

Concurrency mode: optimistic

Created a small model with Optimistic concurrency mode, using the default Timestamp as concurrency token property.
The generated code cannot be compiled due to generation of a line in several methods:

Timestamp = _timestamp;

where _timestamp is not declared at all, but it mentioned as parameter of the method in he documentation comment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.