Multiple FluentMetadataSources for One Model

Thread is closed for posting
1 posts, 0 answers
  1. Cory
    Cory avatar
    13 posts
    Member since:
    Nov 2014

    Posted 22 Feb 2017 Link to this post


    I have an application that must work with both an MsSql database and an Oracle database (never at the same time). The two databases are essentially the same with a few minor differences (e.g. view names, field names, date fields instead of datetimes). Unfortunately, I am unable to the modify the structure of these databases.

    For this reason, I've created two classes which inherit from the FluentMetadataSource classes, one for each backend. Both of them implement the exact same classes and properties, they're just mapped slightly differently. I'd like to have a single model which implements either the MsSql metadata or the Oracle metadata depending on a config file setting. E.g.:

    private static FluentMetadataSource metadataSource = GetMetadataSource();
    private static FluentMetadataSource GetMetadataSource()
        if (ConfigurationConstants.DatabaseBackend.ToLower() == "mssql")
            return new SqlMetadataSource();
        else if (ConfigurationConstants.DatabaseBackend.ToLower() == "oracle")
            return new OracleMetadataSource();
            throw new ArgumentException("Invalid configuration for DatabaseType");


    However, any table/view/column name changes between the two metadata classes get picked up by the enhancer and I am unable to compile:

    Found explicit primitive change to 'Name' which says that the old value etc., etc.

    Is it possible to implement a single model with a single connection string that implements one of two possible FluentMetadataSources? Keep in mind that I would only ever need the model to implement ONE of the metadata classes. Users will have either an MsSql database OR an Oracle database, never both.

    Any help would be appreciated, 


Back to Top