我是.NET Core的新手,我有一个.NET Core WebAPI项目MyWebApp
,我也有.Net Core Class Library项目MyLib使用EntityFrameworkCore
当我尝试使用添加迁移时,我收到错误
指定的deps.json [...\MyWebApp\bin\Debug \netcoreapp1.1\MyWebApp.deps.json]不存在
检查文件夹,我注意到我在[...\MyWebApp\bin\Debug \netcoreapp1.1\win10-x64\MyWebApp.deps.json]中有这个文件
但我真的无法想象我应该做些什么来解决这个问题.
myWebApi project.json:
{
"dependencies": {
"ShopManager": "1.0.0-*",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "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.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.NETCore.App": "1.1.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"runtimes": {
"win10-x64": ""
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": …Run Code Online (Sandbox Code Playgroud) entity-framework ef-migrations entity-framework-core .net-core project.json
我有一个带有集合的ViewModel,例如:
public class CreateCampaignViewModel : ControlPanelViewModel
{
[RequiredField]
public string Name { get; set; }
public List<AdvertisementViewModel> Advertisements { get; set; }
...
}
Run Code Online (Sandbox Code Playgroud)
在视图中,如果我使用它像:
@for (int i = 0; i < Model.Advertisements.Count; i++)
{
<fieldset style="z-index: 0;">
<legend>?????</legend>
<table style="width: 100%;">
<tr>
<td>
<label for="@Html.NameFor(m => m.Advertisements[i].Title)">????? ???????</label></td>
<td>@Html.TextBoxFor(m => m.Advertisements[i].Title)</td>
</tr>
</table>
</fieldset>
}
Run Code Online (Sandbox Code Playgroud)
一切都很好,当我发布表格时我可以看到列表......
但我想将AdvertisementEditor嵌套在Partial View中,因此我的视图变为:
@for (int i = 0; i < Model.Advertisements.Count; i++)
{
Html.RenderPartial("AdvertisementEditor", Model.Advertisements[i]);
}
Run Code Online (Sandbox Code Playgroud)
和我的部分:
@model Pushed.Models.AdvertisementViewModel
<fieldset style="z-index: 0;">
<legend>?????</legend>
<table …Run Code Online (Sandbox Code Playgroud) indexing collections asp.net-mvc asp.net-mvc-partialview asp.net-mvc-viewmodel
我想测试垃圾收集器,但这样做很困难。
我写了以下琐碎的测试代码:
using System;
class Foo
{
int i;
public Foo(int v)
{
i = v;
Console.WriteLine($"{i} was born");
}
~Foo()
{
Console.WriteLine($"{i} has died");
}
}
public class Program
{
[STAThread]
public static void Main(string[] args)
{
Foo n1 = new Foo(1);
Foo n2 = new Foo(2);
Foo n3 = new Foo(3);
Foo n4 = new Foo(4);
Console.WriteLine("built everything");
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true);
GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(1000);
n1 = null;
n2 = null;
n3 = n4;
Console.WriteLine("deref n1..n3");
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, …Run Code Online (Sandbox Code Playgroud) .net ×1
.net-core ×1
asp.net-mvc ×1
c# ×1
collections ×1
finalizer ×1
indexing ×1
project.json ×1
roslyn ×1