Cannot Define Keys on Type Deriving From. Only Root Type in Entity Inheritance Hierarchy Can Contain Keys

This applies to ASP.NET Web API under MVC 4 and .Net 4.5

This error message is from ASP.NET Web API when I implemented using ODataConventionModelBuilder.


GetEdmModel() is my ODdataConventionModelBuilder and what causing this is that I didn’t specify .DerivesFrom() on the type that inherit from others. In my case, Driver inherits from User.

To get around this, I have to include .DerivesFrom() in ODataConventionModelBuilder.

ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();

// Derived class must be specified.

// Exposed enitites to Odata

More on OData in Web API alpha release, “ODataConventionModelBuilder and inheritance”

FluentValidation: Implicit Required Attribute

In my ASP.NET MVC’s Add Implicit Required post, I encountered duplicate validations on same field that causing errors. Well, there’s another strange behavior after that issue was tackled.

This time, no error. But same problem.

Fluent Validation, a free validation framework that I use, also have implicit required attribute and it’s set to true by default. So, to configure it to false:

FluentValidationModelValidatorProvider.Configure(x =>
    x.ValidatorFactory =
    x.AddImplicitRequiredValidator = false;

ValidatorFactory is just dependency injection for FluentValidation. What set the implicit required to false is AddImplicitRequiredValidator.

AntiForgeryToken: A Claim of Type NameIdentifier or IdentityProvider Was Not Present on Provided ClaimsIdentity

This applies to ASP.Net MVC 4 and .Net 4.5

When converting ASP.NET MVC to Claims-aware app, I would get the following error:

A claim of type ‘’ or ‘’ was not present on the provided ClaimsIdentity. To enable anti-forgery token support with claims-based authentication, please verify that the configured claims provider is providing both of these claims on the ClaimsIdentity instances it generates. If the configured claims provider instead uses a different claim type as a unique identifier, it can be configured by setting the static property AntiForgeryConfig.UniqueClaimTypeIdentifier.

At default, ASP.NET MVC uses User.Identity.Name as anti-forgery token to validate form submitted. Worth to note that by default, ASP.NET MVC is not Claims-aware app.

When converting to Claims-aware app, ASP.NET MVC doesn’t use User.Identity.Name as the anti-forgery token anymore. Instead, it attempts to use the NameIdentifier and IdentityProvider ClaimType.


One way to solve it is to set AntiForgeryConfig to use other ClaimType.

protected void Application_Start()


    AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Email;

Add NameIdentifier and IdentityProvider ClaimTypes

Alternatively, you can add NameIdentifier and IdentityProvider ClaimTypes to your claims.

List<Claim> _claims = new List<Claim>();
_claims.AddRange(new List<Claim>
    new Claim("", _user.Email)),
    new Claim("", _user.Email)

LINQ Select Distinct in Flat Data

Have a flat data schema, such as

public class Account {
    public int ID {get;set;}
    public string Name {get;set;}
    public int UserID {get;set;}

If I have a list of this flat data, sometime it’s necessary to get unique data. This is how I go about doing it

var nonUnique = new List<Account>{
    new Account {
        ID = 1,
        Name = "A",
        UserID = 1
    new Account {
        ID = 1,
        Name = "A",
        UserID = 2
    new Account {
        ID = 2,
        Name = "B",
        UserID = 4

var unique = (from m in nonUnique select new { Id = m.ID, Name = m.Name }).Distinct();


unique variable contains distinct data of non-unique.

The output is following:


Validation Was Seen More Than Once: Implicit Required Attribute

I recently encountered a duplicate validation error in ASP.Net MVC. At first, this error is mystery to me because it still gave me exception error after I disabled ALL my validations.


Turns out, this is an easy fix. Root cause is by default MVC set AddImplicitRequiredAttributeForValueTypes property to true. This basically means validation is automatically performed on value type. In my case, I have CountryId as follow:

public class Country {
    public int CountryId { get; set; }

Since CountryId is not nullable, MVC add require validation for the property.

To fix this, you can either set your value type to nullable or set AddImplicitRequiredAttributeForValueTypes to false.

Nullable Value Type

Notice the int is now int?

public class Country {
    public int? CountryId { get; set; }


Set AddImplicitRequiredAttributeForValueTypes to false in your Global.asax.cs.

DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;

Resource: MSDN

Bonita Windows Server Installation on Tomcat


Installation Steps

  • Install JRE by clicking on the downloaded file.
  • Install JDK by clicking on the downloaded file.
  • Unzip Apache Tomcat file to a folder, use this path as <TOMCAT_HOME>.
  • Unzip Bonita Open Solution Deployment file to a folder. This folder is referenced as <BOS-5.9-DEPLOY> in the installation guides.
  • Follow this instruction:

    1. Skip “Download Tomcat” section.
    2. Skip “Download server files” section.
    3. Configure JAAS authentication and communication” section is not necessary if you are not using custom authentication. Follow this step if changes to JAAS authentication is required, for example, use LDAP for authentication.
    4. Configure BOS Tomcat for other databases” section is not necessary if you are not planning to use different database.
  • Add environment variable:
    1. Follow this instruction to add environment variables:
    2. Value for “JRE_HOME” and “JAVA_HOME” depend on version of JRE and JDK you downloaded. Make sure the value reflect to folder where the installation is.
    3. Add JRE_HOME
      1. key: JRE_HOME
        value: C:\Program Files (x86)\Java\jre7
    4. Add JAVA_HOME
      1. key: JAVA_HOME
        value: C:\Program Files (x86)\Java\jdk1.7.0_13

Startup / Shutdown Tomcat

It’s necessary to startup / shutdown Tomcat in proper way before replacing / modify any file in <TOMCAT_HOME> folder.

To startup Tomcat

  • On command prompt, browse to <TOMCAT_HOME>\bin folder.
  • Run “startup.bat” file.

To shutdown Tomcat

  • On command prompt, browse to <TOMCAT_HOME>\bin folder.
  • Run “shutdown.bat” file.

Running Bonita User Experience


You can install Bonita REST API with the following step:

  • Copy <BOS-5.9-deploy>\bonita_execution_engine\interfaces\REST\with_execution_engine_without_client\bonita-server-rest.war
  • Paste the file into <TOMCAT_HOME>\webapps

Running Bonita REST API

If you need to use an REST client, you must have acknowledgement of the Bonita HTTP API. All HTTP requests will be done using the POST method.

All requests, except checkUserCredentials, checkUserCredentialsWithPasswordHash and getIdentityKeyFromTemporaryToken, will require authentication using HTTP Basic.

To generate your first REST API call, follow this step under “REST client“:

Bonita (Pretty) Basic

Bonita is pretty! (pun intended)

Pretty Little Background

BonitaSoft is a company behind Bonita Open Solution, a powerful and scalable open source BPM software.

Bonita Open Solution is free and open source. You can even download the source code if you care.

If you ever wonder, they make money by providing training, consulting and subscription pack (SP) which is paid version of Bonita Open Solution (includes many other features not available in free version).


Bonita Open Solution (contains Bonita Studio, Bonita Execution Engine and Bonita User Experience)

Source Code


Java Runtime Environment (JRE).


Official documentation

Community Support
This is another resource for support. You can find forums, blog, and various way to improve products (issue tracker, contribute to open source), etc.


For all Intro Tutorials (PDFs), you will need to login to download.


Bonita Open Solution (contains Bonita Studio, Bonita Execution Engine and Bonita User Experience)