gpt4 book ai didi

C#调用基类构造函数混淆

转载 作者:太空宇宙 更新时间:2023-11-03 23:25:06 24 4
gpt4 key购买 nike

在我的 asp.net MVC 应用程序中,我使用 Entity Framework 和身份进行用户身份验证。所以我的 DbContext 类如下所示(有效):

public class PropertyContext : IdentityDbContext<AppUser>
{
public PropertyContext() : base("name=PropertyBDConnection") { }
...
}

我将一个字符串传递给 PropertyContext 的基本构造函数。因此,我可以假设 IdentityDbContext 有一个将字符串作为参数的构造函数。

但是在 asp.net identity ( here IdentityDbContext.cs) 的 github 存储库中,我发现了以下内容-

public class IdentityDbContext<TUser> : 
IdentityDbContext<TUser, IdentityRole, string>
where TUser : IdentityUser
{ }

根本没有构造函数。当然,我遗漏了一些东西或找错了地方。

最佳答案

是的,您找错地方了:根据文档,IdentityDbContext has three constructors ,其中一个接受 string:

  • IdentityDbContext()
  • IdentityDbContext(DbConnection, DbCompiledModel, Boolean)
  • IdentityDbContext(String)

关于C#调用基类构造函数混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34068876/

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