Generate ASP.NET Core WebAPI model with Entity Framework Core Generator

Overview

In this tutorial, you’ll learn how to use the Entity Framework Core Generator to create an Entity Framework Core data model for an ASP.NET WebAPI. Entity Framework Core Generator (efg) is .NET Core command-line (CLI) tool to generate Entity Framework Core model from an existing database.

The code for this tutorial is available at https://github.com/pwelter34/EntityFrameworkCore.Generator.Demo

Tracker Database

This tutorial will be a database first model. The database is a simple task tracking database.


Entity Framework Core Generator - Generating a model from an existing database

Overview

.NET Core command-line (CLI) tool to generate Entity Framework Core model from an existing database.

Features

  • Entity Framework Core database first model generation
  • Safe regeneration via region replacement
  • Safe Renaming via mapping file parsing
  • Optionally generate read, create and update models from entity
  • Optionally generate validation and object mapper classes

Documentation

Entity Framework Core Generator documentation is available via Read the Docs

Installation

To install EntityFrameworkCore.Generator tool, run the following command in the console


EntityChange - Library to compare two entity object graphs

Overview

Library to compare two entity object graphs detecting changes

Features

  • Compare complete entity graph including child entities, collections and dictionaries
  • Collection compare by index or element equality
  • Dictionary compare by key
  • Custom value string formatter
  • Custom entity equality compare
  • Markdown or Html change report formatter

Download

The EntityChange library is available on nuget.org via package name EntityChange.

To install EntityChange, run the following command in the Package Manager Console


MongoDB.Messaging - MongoDB Messaging Library

Overview

The MongoDB Messaging library is a lightweight queue pub/sub processing library based on MongoDB data store.

Features

  • Easy to use Fluent API
  • Self creating and cleaning of Queues
  • Configurable message expiration
  • Generic data payload
  • Trigger processing from oplog change monitoring
  • Configurable auto retry on error
  • Message processing timeout
  • Scalable via subscriber worker count
  • Supports distributed locks

Download

The MongoDB.Messaging library is available on nuget.org via package name MongoDB.Messaging.

To install MongoDB.Messaging, run the following command in the Package Manager Console


DataGenerator - Generate Intelligent and Realistic Test Data

Features

  • Generate intelligent test data based on property type and name
  • Automatic discovery of data sources
  • Fully customizable property data sources
  • Realistic data sources
  • Weighted value selection
  • Easy fluent API

Download

The DataGenerator library is available on nuget.org via package name DataGenerator.

To install DataGenerator, run the following command in the Package Manager Console

Install-Package DataGenerator

NuGet Version

Configuration

Full class property configuration

Generator.Default.Configure(c => c
  .Entity<User>(e =>
  {
    e.Property(p => p.FirstName).DataSource<FirstNameSource>();
    e.Property(p => p.LastName).DataSource<LastNameSource>();
    e.Property(p => p.Address1).DataSource<StreetSource>();
    e.Property(p => p.City).DataSource<CitySource>();
    e.Property(p => p.State).DataSource<StateSource>();
    e.Property(p => p.Zip).DataSource<PostalCodeSource>();
    
    e.Property(p => p.Note).DataSource<LoremIpsumSource>();
    e.Property(p => p.Password).DataSource<PasswordSource>();
    
    // array of values
    e.Property(p => p.Status).DataSource(new[] { Status.New, Status.Verified });
    
    
    // don't generate
    e.Property(p => p.Budget).Ignore();
    
    // static value
    e.Property(p => p.IsActive).Value(true);
    
    // delegate value
    e.Property(p => p.Created).Value(() => DateTime.Now);
  })
);

Example of configuration for generating child classes