Contents tagged with Tools

  • Entity Developer Review, Part 3

    Here is part 3 of my exploring Entity Developer series, this time, on Entity Framework. Read the first part here and the second here.

    So, this time I decided to use Entity Developer to generate a database from an Entity Framework Code First model:


    I was then asked if I wanted to synchronize my model with a database later on, which seems like a good idea:


    Next, I am asked about the target server, interesting, all databases for which I have an ADO.NET provider installed are present:


    A naming configuration screen for classes and properties is shown, similar to its NHibernate counterpart, with the curious exception of the option to remove invalid characters:


    Next, some namespace and Entity Framework version options:


    I chose Entity Framework 6 and then I got to chose the template:


    Again, a number of templates exist, for both POCO, self-tracking (Entity Framework 4) entities, repository pattern, MVC, WCF RIA Services, etc, for C# as well as Visual Basic:


    Because I started with model first (or code first), I am presented with an empty diagram. Weird, I got a validation message about not being able to find the Entity Framework 6 assembly, but it didn’t seem to affect the entities’ generation:


    While generating the model, we can add spatial types as properties (if the target database server supports them), which is nice:


    Everything seemed to work, from generating the database from the model, to the actual classes. We get to tune some of the DbContext options such as LazyLoadingEnabled through the model settings:


    It is also possible to specify stored procedures for the DELETE, INSERT and UPDATE operations, but only if one stored procedure exists in the model.

    So, to add it up, everything worked as expected, the functionality is similar to that when using an NHibernate model.

    Coming next, advanced usages of Entity Developer.


  • Entity Developer Review, Part 2

    Here’s my second post on Entity Developer, this time, focused on NHibernate. You can find the first part here.

    I created a new model item of type NHibernate and chose the option to generate from the database:


    Mind you, you need to have the database providers installed for the databases you want to access, Entity Developer does not include them.I was then presented with a list of database objects:


    After I selected a few, Entity Developer shows the class and properties naming rules dialog:


    Next, some more options, pretty complete. Very useful is the option to detect many-to-many associations and table per type inheritances. These will be the default settings, but we can override them on a class by class basis:


    Interesting, the next dialog gives an opportunity to split entities among different diagrams according to the database object’s schema:


    Finally, we get to choose the template that will be used to generate the classes (the only included one is for HBM.XML) and set some of its properties, like, generate a single file or one file per entity, implement standard methods such as Equals or GetHashCode, standard interfaces like NHibernate’s IValidatable, ICloneable and INotifyPropertyChanged, add data contract serialization attributes for WCF and add support for a validation framework (NHibernate Validator, Data Annotations or Enterprise Library Validation Application Block):


    There are several templates available, in both C# and Visual Basic, which we can browse and select (others can be added manually):

    The code is immediately generated, unless there are validation errors in the model, like, a table without primary key:


    In the Model window, selecting a class or a property of a class, we can set its properties, I think all of NHibernate’s features are there, collection types, cascading options, id generators, etc, plus validation settings, which will be translated to the validation framework of choice.

    The HBM.XML files are set as embedded resources, which is also nice, and the Web.config file is updated with the connection string to the selected database. Weird, the dialect was set to MsSql2005Dialect, which doesn’t make much sense since I was connecting to SQL Server 2014. It is possible to select another dialect through the user interface, but dialects and drivers appear as text boxes, not much of a help.

    All in all, it’s pretty impressive, it seems that all NHibernate features are present – did I mention that it is even possible to configure filters? – making Entity Developer a very interesting product. Another strong point is the T4 template system, which, with some effort, allows us to generate code mappings or whatever we want. The only problem I see is that no template for NHibernate's built-in mapping by code is supplied, although one exists for Fluent NHibernate.

    Next, Entity Framework.


  • Entity Developer Review, Part 1


    I recently started to use Entity Developer, by Devart, to generate entities from my databases. It is a commercial product, mind you, and I am in no way affiliated with them, I just happen to like it, so I am going to talk a bit about it.

    A very strong point is that it supports out of the box NHibernate, Entity Framework and the now half-forgotten LINQ to SQL, which makes it stand out from other products. This is not going to be a thorough review, but I will post more as soon as I explore things in more depth.

    Look and Feel

    In general, the UI has a classic Windows appearance, with multiple floating windows, and there are a couple of skins available, but I didn’t pay much attention to it.


    There’s a Database Explorer window which allows us to browse our databases and to see what’s in there (tables, views, functions and stored procedures), plus we can drag objects from it into the Diagram window, which will add this objects to the model.

    The Diagram window allows automatic layout of the objects in it, having each in different colors, adding notes (nice!) and new model items (classes, inheritances, associations, enumerations. A diagram can be “stamped” with the author’s details (name, company, version, date, etc), which is good if we are to print it or generate a bitmap from it (supported natively). It can be zoomed and there’s a Diagram Overview window that shows the full model at once, so that we can easily spot objects outside of the visible area.

    There may be several diagrams for an entity model, the core of an Entity Developer project, and this model has it’s own window, on which we can explore it and see all the mapped database objects and corresponding model items, including inheritances, associations, components (complex/value types), etc. We also have there the list of templates available for the current project type.

    There’s the possibility to generate a SQL script from the model, but in NHibernate projects, only databases SQL Server, SQL Server Compact Edition, Oracle, MySQL and PostgreSQL, this requires that the proper .NET providers are present. For Entity Framework projects, I could only find the option to generate the script for SQL Server, and, of course, LINQ to SQL only supports SQL Server as well. There’s an option for updating the model from the database as well, in case we chose to generate it from the database.

    It is of course possible to validate the model, and the Error List window will present all outcomes of this validation, which can either be errors or warnings. A nice thing: double clicking on a notification, we jump directly to the model item that caused it. It would be interesting as well to have the option to quick fix the problem, but I reckon it’s not always possible or easy to do in an automated fashion.

    When it comes to actually generating the code, there are an endless number of options, from capitalization of properties, lazy loading of associations, inclusion of foreign keys, etc. These settings are of course dependent on the project (NHibernate, Entity Framework or LINQ to SQL), because not all libraries have the same features. The generation is based on T4 templates, which is nice, because they are a standard in .NET. Only one template for each API is include, but it is very easy to write our own, by copying from an existing one and modifying it to our liking. I have yet to find a T4 debugger, Entity Developer, unsurprisingly, does not offer one.


    OK, so far I have talked in general about Entity Developer, in my next posts, I will talk about NHibernate and Entity Framework specifics and also about advanced functionality.


  • Instant StyleCop Code Analysis How-to Review

    Instant StyleCop Code Analysis How-to

    In the past days I’ve been reading Instant StyleCop Code Analysis How-to. Having interest in static code analysis, I have always been interested in StyleCop and FxCop, Microsoft’s static analysis tools, so this came with great interest.

    I must say it was an interesting read, although it covers some tools that I don’t use – Jenkins, Hudson and NAnt, to be precise. It is a short book, and easy to follow.

    The first chapter shows how to install StyleCop and how to integrate it with the various Visual Studio editions still around, from 2008 to 2012 (still not 2013, of course).

    Next, it goes on to talk about integrating with Resharper, the productivity tool we all love, so that it uses StyleCop’s rules besides its own. You must be aware that specific Resharper versions only work with appropriate StyleCop ones; you will find a compatibility matrix at StyleCop’s web site.

    Then it moves on to explain how to integrate with MSBuild, the build engine used by Visual Studio. This will allow us to have compile time checks, which is definitely a good thing.

    The next chapter talks about running StyleCop from the command line, which is also useful for automation/continuous integration scenarios.

    NAnt is next, then Hudson and Jenkins (successor/fork of Hudson), which I honestly haven’t read because I don’t use them. I would sure welcome a chapter on Team City and Team Foundation Server, or even Team Foundation Service instead, but…

    The book goes on to talk about how to customize document headers (comments), so as to prevent violations.

    Following that, my favorite chapter, on creating custom rules. Granted, this chapter is identified as simple, but I would sure appreciate if it had gone a bit further.

    The final chapter explains how we can integrate StyleCop with our own tools, by providing a working example of a real-time analysis tool for MonoDevelop. I’m not a MonoDevelop user myself, but the concepts are interesting.

    All in one, it is an interesting and easy to read book, but don’t expect advanced contents! Smile


  • Visual NHibernate Update

    I have previously talked about Visual NHibernate. It has grown since last time, now offering support for multiple databases (SQL Server, Oracle, MySQL, PostgreSQL, Firebird), generates projects from existing databases or from existing Visual Studio projects and produces XML or Fluent mappings, to name just a few. To me it is by far the most interesting tools for working with NHibernate I know of (granted, I haven't tried NHibernate Profiler).