有谁知道如何更改以下命令的输出目录:
dotnet ef migrations add Initial --context EsportshubApi.Models.ApplicationDbContext
Run Code Online (Sandbox Code Playgroud)
??
我试图添加选项:
--content-root-path 'Migrations/Identity'
Run Code Online (Sandbox Code Playgroud)
但那没有做任何事情.还有一个--data-dir选项以及其他与目录相关的选项,但它们都不是迁移的输出.
我的问题是我有2个DbContexts所以我希望他们的迁移分开.
asp.net entity-framework command-line-interface asp.net-core
我在linux上使用dotnet core 1.1,当我想从我的常规dbContext中分离identityContext时,我遇到问题,每当我在startup.cs中运行以下行时 - > configure:
//... some other services
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
serviceScope.ServiceProvider.GetService<ApplicationDbContext>().Database.Migrate();
//running other database.migrations here + seeding data. But it is the line above that causes problems
Run Code Online (Sandbox Code Playgroud)
因此,该行抛出异常:实体类型'IdentityUserLogin'需要定义主键
我根本不明白这一点,为什么我的工作是给IdentityUserLogin一个主键?它是一个第三方类,我甚至没有触及它.我有以下简单的设置:
namespace EsportshubApi.Models
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
public ApplicationDbContext()
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
}
Run Code Online (Sandbox Code Playgroud)
和applicationUser:
namespace EsportshubApi.Models.Entities
{
public class ApplicationUser : IdentityUser
{
public ApplicationUser() { }
public …Run Code Online (Sandbox Code Playgroud) 我正在使用linux上的dotnet核心,我正在尝试使用连接字符串配置我的DbContext到mysql Server.
我的DbContext看起来像这样:
using Microsoft.EntityFrameworkCore;
using Models.Entities;
namespace Models {
public class SomeContext : DbContext
{
//alot of dbSets...
public DbSet<SomeEntity> SomeDbSet { get; set; }
public EsportshubContext(DbContextOptions<SomeContext> options) : base(options) {
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMysql //Cannot find this method
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//using modelBuilder to map some relationships
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的依赖关系看起来像这样:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", …Run Code Online (Sandbox Code Playgroud) 我的dotnet核心应用程序中有以下依赖项:
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Moq": "4.0.10827"
},
Run Code Online (Sandbox Code Playgroud)
无论我下载什么版本的Moq,它只是不受支持,它说:
Package Moq 4.0.10827 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Moq 4.0.10827 supports:
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- sl4 (Silverlight,Version=v4.0)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.
Run Code Online (Sandbox Code Playgroud)
但是我在这篇博文上看到:.NET Core上的Moq它是可能的,我在工作室代码中有nuget插件,所以它自动填充包,我写的时候找不到任何包moq.netcore可能我要求更多的查找方法如果这样的插件实际存在,不仅仅是一个答案,因为现在我无法看到nuget如果dotnet Core支持包,那么你们如何检查它是否有支持?你是否只在Nuget.org上寻找包裹?
谢谢
编辑:解决方案project.json:
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"moq": "4.6.38-alpha"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform", …Run Code Online (Sandbox Code Playgroud) 因此,正如标题所述,我想知道是否有可能用dotnet cli做相当于“ npm run”的动作?例如,此片段来自我的project.json:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Configuration": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
"Microsoft.AspNetCore.Mvc":"1.1.0",
"Microsoft.EntityFrameworkCore": "1.1.0",
//"MySql.Data.Core": "7.0.4-ir-191",
//"MySql.Data.EntityFrameworkCore": "7.0.4-ir-191",
"SapientGuardian.EntityFrameworkCore.MySql": "7.1.14",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"moq": "4.6.38-alpha",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Relational": "1.1.0"
},
"scripts": {
"migrate-identity": "dotnet ef database update --context 'ApplicationDbContext'"
},
Run Code Online (Sandbox Code Playgroud)
迁移身份是我添加的自我身份,可以执行此脚本吗?
否则我想我只会在我的项目中有一个scripts文件夹,没什么大不了的,但仍然:)
我希望本地开发一些web组件,即使互操作性不是很好.所以我在我的ubuntu操作系统上的chrome:// flags标签下启用了google-chrome-stable版本50.0.2661.102的实验性网络平台功能...但我仍然只有不推荐使用(根据developer.mozilla文档的链接)方法:
document.registerElement( {...})
在Firefox中也一样.我知道如果我安装了聚合物,那么polyfill会修复它,但据我所知,聚合物api与W3C标准不是100%相同.有没有人设法使用最新标准在浏览器中本地试用Web组件?特别是这部分标准我想试试:
2.1.1 Creating an autonomous custom element
This section is non-normative.
For the purposes of illustrating how to create an autonomous custom element, let's define a custom element that encapsulates rendering a small icon for a country flag. Our goal is to be able to use it like so:
<flag-icon country="nl"></flag-icon>
To do this, we first declare a class for the custom element, extending HTMLElement:
class FlagIcon extends HTMLElement {
constructor() {
super();
this._countryCode …Run Code Online (Sandbox Code Playgroud) javascript google-chrome cross-browser web-component custom-element
我只是在学习F#,所以我正在尝试一些事情(我知道可以使用XUnit或其他东西)
我有以下断言方法,并且想法是它应该采用预期的异常和它期望抛出此异常的函数,然后执行函数并在with测试内部如果抛出的异常与预期的异常相同.
let assertException (testName : string) (expected : 'a when 'a :> Exception) functionToBeTested =
try
functionToBeTested
(false)
with
| :? Exception as someException when someException :? expected ->
printTestResultInMiddle (sprintf "Test: %s PASSED: Raised expected exception %A" testName expected) true
(true)
| _ ->
printTestResultInMiddle (sprintf "Test: %s FAILED: expected exception %A" testName expected) false
(false)
Run Code Online (Sandbox Code Playgroud)
它给了我在Unexpected symbol '(' in pattern matching. Expected '->' or other token. 尝试调用print方法的行中的错误.我不应该把它try ... with当作一个对待
match ... with
Run Code Online (Sandbox Code Playgroud)
??
还有一个问题,我可以轻松地做到这一点吗?
asp.net-core ×5
c# ×2
asp.net ×1
assert ×1
exception ×1
f# ×1
javascript ×1
json ×1
moq ×1
mysql ×1
nuget ×1
project.json ×1
testing ×1