I am using WebAPi project and I would like to setup EntityFramework 6 with Mongodb.
I have setup my mongodb database and my entity framework code first model by following this link:
http://cdn.rssbus.com/help/DG1/ado/pg_efCodeFirst.htm
Now I would like to get Entity Framework and Asp.net Identity 2 to work together based on Mongodb. However, I cannot find any way ormodules that allow to do it. I found the following but it explains to uninstall entity framework.
https://github.com/g0t4/aspnet-identity-mongo
So would you know a tuorial or would you have any experiences to enable mongodb for EF Code first and with IDentity working with?
THanks,
There is no official MongoDb provider implementation for EF core at this time, I did not see any mention of MongoDb in the . net core 7 (the next version) roadmap as of now.
When you use NoSQL databases for your infrastructure data tier, you typically do not use an ORM like Entity Framework Core. Instead you use the API provided by the NoSQL engine, such as Azure Cosmos DB, MongoDB, Cassandra, RavenDB, CouchDB, or Azure Storage Tables.
Now that we have a running API that manages products and their prices using Entity Framework Core, we can now integrate Dapper into the solution and apply what we learned at the start of this article.
Ok so I finally found a solution.
I am not using EF anymore.
I am using AspNet Identity Mongo with the V2 branch I compiled.
https://github.com/InspectorIT/MongoDB.AspNet.Identity/tree/v2
I am using MongoRepository for the repository of my Model.
https://github.com/RobThree/MongoRepository
And I have developed a DataService to manage my models CRUD operations.
public class DataService
{
public static MongoRepository<ModelClass> ModelClass{ get { return Singleton<MongoRepository<ModelClass>>.Instance; } }
}
public class Singleton<T> where T : class, new()
{
Singleton() { }
private static readonly Lazy<T> instance = new Lazy<T>(() => new T());
public static T Instance { get { return instance.Value; } }
}
And I am good.
Thanks,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With