Updating MongoDB C# driver to 1.9.2 and mongoRepository to 1.6.6 broke inheritance processing

273 views Asked by At

Recently I've updated my mongoRepository & driver packages from 1.6.1/1.8.3 to 1.6.6/1.9.2. After that it does not recognize my classmaps any more. I've written a simple app to demonstrate that

public abstract class A:Entity
{
    public string Prop1 { get; set; }
}

public class B : A
{
    public string Prop2 { get; set; }
}

public class C : A
{
    public string Prop3 { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        BsonClassMap.RegisterClassMap<B>();
        BsonClassMap.RegisterClassMap<C>();

        var repo1 = new MongoRepository<B>("mongodb://localhost/MongoTest")
        {
            new B() {Prop2 = "0"},
        };

        var repo2 = new MongoRepository<C>("mongodb://localhost/MongoTest")
        {
            new C() {Prop3 = "1"},
        };

    }
}

After running this code I get two collections named B and C but it must be one collection named A and contain _t field inside every entity

Did I miss something when upgrading to the latest version?

1

There are 1 answers

0
John dow On

It was a bug in MongoRepository 1.6.6.

1.6.7 is released