gpt4 book ai didi

c# - EntityFramework 6 和 mongodb 和 Identity

转载 作者:IT老高 更新时间:2023-10-28 13:35:24 24 4
gpt4 key购买 nike

我正在使用 WebAPi 项目,我想用 Mongodb 设置 EntityFramework 6。

我已经通过以下链接设置了我的 mongodb 数据库和我的 Entity Framework 代码第一个模型:

http://cdn.rssbus.com/help/DG1/ado/pg_efCodeFirst.htm

现在我想让 Entity Framework 和 Asp.net Identity 2 基于 Mongodb 一起工作。但是,我找不到任何允许这样做的方式或模块。我发现了以下内容,但它解释了卸载 Entity Framework 。

https://github.com/g0t4/aspnet-identity-mongo

那么您是否知道教程或者您是否有任何经验来首先为 EF 代码启用 mongodb 并与 IDentity 一起使用?

谢谢,

最佳答案

好的,我终于找到了解决方案。

我不再使用 EF。

我将 AspNet Identity Mongo 与我编译的 V2 分支一起使用。

https://github.com/InspectorIT/MongoDB.AspNet.Identity/tree/v2

我正在使用 MongoRepository 作为模型的存储库。

https://github.com/RobThree/MongoRepository

我还开发了一个 DataService 来管理我的模型 CRUD 操作。

 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; } }
}

我很好。

谢谢,

关于c# - EntityFramework 6 和 mongodb 和 Identity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32099488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com