MongoDB .NET Analyzer 1.5.0 Released

MongoDB .NET Analyzer 1.5.0 Release Notes

This is the general availability release for the 1.5.0 version of the analyzer.

The main new features in 1.5.0 include:

VS-141 New analysis rules introduced: EFCore to MQL:

The new analysis rules enable displaying MQL for MongoDB Entity Framework Core Provider expressions in compile time.

For example:

 var mongoClient = new MongoClient("mongodb://localhost:27017");
 var db = MoviesDbContext.Create(mongoClient.GetDatabase("movies"));

 // LINQ filter query (analyzer provides MQL as an information message)
 var movies = await db.Movies
     .Where(m =>
         m.Genre == genre &&
         m.Score >= minScore &&
         m.Title.Contains(titleSearchTerm))
     .OrderBy(m => m.Score)
     .ToListAsync();

public class MoviesDbContext : DbContext
{
    public DbSet<Movie> Movies { get; set; }

    public static MoviesDbContext Create(IMongoDatabase database) =>
     new(new DbContextOptionsBuilder<MoviesDbContext>()
         .UseMongoDB(database.Client, database.DatabaseNamespace.DatabaseName)
         .Options);

    public MoviesDbContext(DbContextOptions options) : base(options)
    {
    }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
    }
}

Will display the following MQL for the db.Movies query:
db.coll.Aggregate([{ "$match" : { "Genre" : genre, "Score" : { "$gte" : minScore }, "Title" : /titleSearchTerm/s } }, { "$sort" : { "Score" : 1 } }])

VS-156 Support for strong named 2.28 driver.
VS-146 Support fully qualified names for data models.

The full list of JIRA issues resolved in this release is available here.

1 Like

This topic was automatically closed after 90 days. New replies are no longer allowed.