Thinking about model changes when doing MongoDb Aggregations
When writing mongoDB Aggregation quarries in C# it will write as bellow. var UserAccount = new UserAccountModel(); var matchEmail = new BsonDocument { { "$match", new BsonDocument { { "Email", Email } } } }; var projectProfiles = new BsonDocument { { "$project", new BsonDocument { { "_id", 0 }, { "Profile", "UserAccount.UserProfiles" } } } }; var unwindProfile = new BsonDocument { { "$unwind", "$Profile" } }; var matchCompanyId = new BsonDocument { { "$match", new BsonDocument { { "Profile.UserCompanyID", CompanyId } } } }; The result of the above quarry depends on the model CompanyModel and if it has been changed the aggregation will throw an error. As an example, UserAccount.UserProfiles change into UserAccount.UserProfileList To make safe this will not be happen and to get notify when the model has been changed at the compilation level, you can use the following way. ...