Is collection.Save and migrations is necessary?

Hello,
I am trying the build application for mongodb on c#. I have a multiple questions about that.

1-)In SQL, i can migrate (seed) datas with Entity Framework Core(ModelBuilder.HasData). I have a lot of Data(documents) and i do not want to seed my MongoDb databases with MongoDbCompass. Should I write a scipt in C# with db.InsertMany options? What is the best approach for MongoDb?
2-)I wrote a services for CRUD operations. In APIController, i am using this service. I can feed my database with this service. However, my api is directly interacting with database. I want to create repositories but my service and repositories looks the same. What should i do?
3-) In my service, i am using db.InsertOneAsync, ReplaceOneAsync, DeleteOneAsync vs… Should i save the changes after that operation with collection.Save commands or After Insert, replace and delete command database automatically save the changes?

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.