小编Haz*_*zza的帖子

更改Azure网站订阅

我用windows azure进行了免费试用,我离开了这个国家,它已经用光了.

我现在已升级为即用即付帐户.都好.

但是,我之前的网站仍然使用我的旧订阅,有没有办法使用我的新付费订阅来重新激活这些网站?

azure azure-web-sites

38
推荐指数
3
解决办法
3万
查看次数

.NET Core 和 Entity Framework Core 中的数据库优先与身份验证

我想使用数据库优先方法通过 EF Core 管理我的数据库,而不仅仅是初始数据库创建。我使用此命令生成实体模型和映射代码:

Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=MyDB;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models/Entities -f
Run Code Online (Sandbox Code Playgroud)

现在这工作正常。我只是在身份整合方面苦苦挣扎。目前我有两个独立的上下文,一个是由脚手架命令生成的,另一个是身份上下文,如下所示:

public class IdentityContext : IdentityDbContext<ApplicationUser> {
    public IdentityContext(DbContextOptions<IdentityContext> options)
        : base(options) {
    }

    protected override void OnModelCreating(ModelBuilder builder) {
        base.OnModelCreating(builder);
        // Customize the ASP.NET Identity model and override the defaults if needed.
        // For example, you can rename the ASP.NET Identity table names and more.
        // Add your customizations after calling base.OnModelCreating(builder);
    }
}
Run Code Online (Sandbox Code Playgroud)

两个上下文都从同一个数据库读取并注册如下:

services.AddDbContext<ApplicationContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddDbContext<IdentityContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
Run Code Online (Sandbox Code Playgroud)

有两个独立的上下文是否合理?当我开始在用户和其他模型之间创建关系时,它会导致未来出现问题吗?我在文档中找不到有关继续使用db-scaffold来生成实体模型和映射的任何内容。

如果我能澄清任何事情,请告诉我。


原始背景

好吧,很明显我原来的问题没有任何好处。

我只是想澄清一下我使用 .NET …

entity-framework asp.net-identity entity-framework-core asp.net-core

5
推荐指数
0
解决办法
2548
查看次数

Orchard CMS中的SignalR聊天模块

我正在为我正在开发的果园项目构建一个即时聊天模块.我想使用SignalR来启动聊天,但是我遇到了这个困难:

<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

我尝试的一切都收到404错误.我在webconfig中有RAMFAR,我尝试重写IIS上的url.我希望这是一个非常简单的东西,我的大脑很难看到.我甚至不确定SignalR是否与Orchard合作,我怀疑会有一些困难

iis asp.net-mvc orchardcms signalr

4
推荐指数
1
解决办法
2593
查看次数

在 Visual Studio Scaffolder 中获取项目中的所有类

我正在为 Visual Studio 构建一个脚手架工具,并且需要显示从某个抽象类派生的类的列表,但只有活动项目中的类。我有它的工作,但它需要视觉工作室一段时间来运行代码。

ICodeTypeService codeTypeService = (ICodeTypeService)Context
                    .ServiceProvider.GetService(typeof(ICodeTypeService));

var types = codeTypeService.GetAllCodeTypes(Context.ActiveProject);

foreach (var type in types)
{
    type.
    if (type.Kind == vsCMElement.vsCMElementClass)
    {
        foreach (var d in type.Bases)
        {
            var dClass = d as CodeClass;
            var name = type.Name;
            if (dClass.Name == "MyAbstractClass")
            {
                if (type.Namespace.Name.Contains(Context.ActiveProject.Name))
                {
                    yield return type.Name;
                }
            }

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

因此,当它找到匹配的类以确保它在我的项目中时,我必须检查命名空间。这感觉就像我在做很多不必要的工作。这是他们使用脚手架模板 Visual Studio 项目给出的示例:

ICodeTypeService codeTypeService = (ICodeTypeService)Context
                    .ServiceProvider.GetService(typeof(ICodeTypeService));

return codeTypeService
    .GetAllCodeTypes(Context.ActiveProject)
    .Where(codeType => codeType.IsValidWebProjectEntityType())
    .Select(codeType => new ModelType(codeType));
Run Code Online (Sandbox Code Playgroud)

codetypeservice 是正确的方法吗?

编辑 基本上,当它搜索类时,它不仅会在当前活动的项目中进行搜索,还会搜索所有引用的项目。这就是为什么我必须检查命名空间,以便我只能从活动项目中获取结果。我认为这就是它被放慢的原因,因为引用的项目非常大,所以它做了很多完全不必要的工作......

c# visual-studio envdte

4
推荐指数
1
解决办法
1473
查看次数