相关疑难解决方法(0)

如何在asp.net 5项目中启用迁移(EF6)?

我创建了一个新的类库(包)项目(在VS 2015 RC之前使用了更糟糕的asp.net类库名称来表示数据层.只是要清楚这是更新的kproj样式结构.

将EF 6.1.3添加到project.json.目前仅针对DNX451.

   "dependencies": {
        "EntityFramework": "6.1.3"
        ,"Moq": "4.2.1502.911"
    },
Run Code Online (Sandbox Code Playgroud)

创建初始模型类并使用AlwaysCreate数据库初始化程序一切正常.现在需要切换到迁移,以便在包管理器控制台中使用Enable-Migrations并获得:

Enable-Migrations : The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Enable-Migrations
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

对于EF7迁移,迁移命令不支持包管理器.相反,有一个新的ef命令在dnu中运行,但是新进程只适用于EF7而不是EF6吗?

为什么包管理器认为即使引用了EF6,Enable-Migrations仍然无效?

entity-framework-6 asp.net-core

11
推荐指数
1
解决办法
3910
查看次数

ReportingTypes的ASP.NET要求

我正在研究在ASP.NET(MVC Core 1.0)中使用基于声明的授权.设置a时ClaimsIdentity,我提供了一个键/值字符串对列表来表示每个Claim.例:

List<Claim> claims = new List<Claim>
{
    new Claim("UserID", user.ID),
    new Claim("Name", user.Name),
    new Claim("Role", "basic")
};
Run Code Online (Sandbox Code Playgroud)

我的理解是我可以使用我想要的任何键/值.但是我注意到ClaimsType课程中有一些预定义的键可用.所以,我可能会使用其中一些预定义的键:

List<Claim> claims = new List<Claim>
{
    new Claim(ClaimTypes.Sid, user.ID),
    new Claim(ClaimTypes.Name, user.Name),
    new Claim(ClaimTypes.Role, "basic")
};
Run Code Online (Sandbox Code Playgroud)

问题:

  1. 如果我使用预定义的密钥,是否有关于分配给每个密钥的实际值的规则/限制,还是应用程序定义的?例如,是否可以粘贴数据库主键ClaimTypes.Sid,或者ASP.NET是否对ClaimTypes.Sid应该包含的内容有一定的期望?

  2. 是否有任何ClaimTypes需要的,或者是完全由应用程序来决定什么包括或不包括什么呢?我想,答案可能取决于我将与之交互的特定第三方身份验证服务,但是如何使用不包含任何第三方身份验证的自包含ASP.NET项目的简单情况.ASP.NET本身是否有任何要求?

任何与使用特定键/值的要求和/或最佳实践的链接都将受到赞赏.

claims-based-identity asp.net-core-mvc asp.net-core

9
推荐指数
2
解决办法
4109
查看次数