circles-arrows / blueprint41

An Object Graph Mapper for CSharp to connect to Neo4j or Memgraph.
http://www.blueprint41.com/
MIT License
31 stars 8 forks source link

Crash in Neo4jPersistenceProvider#FetchDatabaseInfo #80

Open robotgryphon opened 3 days ago

robotgryphon commented 3 days ago

I'm not sure what exactly the reproduction steps are; it looks like the Neo4j persistence manager blows up trying to read an empty collection (LINQ First instead of handling a null w/ FirstOrDefault)

image

Relevant code: https://gist.github.com/robotgryphon/a8c9a873b8aba5eac917a4198424724d

Database set up:

renkokarman commented 2 days ago

Try to change your code from:

if(!dataModel.HasExecuted)
    dataModel.Execute(false); // <<<< DIES HERE

to:

dataModel.Execute(true);

The idea is that you can execute the rebuild of the data model (in memory) by applying the scripts that build up your model one at a time. If you supply "true" as the argument, Blueprint41 will generate and apply upgrade scripts to your datastore/graph, if the datastore did not have them applied before.

Therefore, you should always "Execute" the model with upgradeDatastore=true before you make any changes to your database. Preferably it's one of the first things you do at the application's main entry point.

So, when would you use the option to "Execute" the model with upgradeDatastore=false then? It's there for the scenario when your program needs to use the model but there is no datastore/graph available at runtime. For example, if you want to query the entities and relations from the model directly to generate documentation of your data model. You might want to do that automated from a build pipeline that has not permissions to connect to the datastore.