当我在VS 2017包管理器控制台中使用dotnet ef工具时,我收到有关需要更新EF Core工具的警告消息:
PM> dotnet ef migrations list -s ../RideMonitorSite
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.2-rtm-30932'. Update the tools for the latest features and bug fixes.
20180831043252_Initial
Run Code Online (Sandbox Code Playgroud)
但是我的csproj文件有这个条目:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.2" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
我已经确认安装的版本实际上是过时的:
PM> dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.1-rtm-30846
Run Code Online (Sandbox Code Playgroud)
那么我该如何更新工具呢?顺便说一下,我在其他答案中看到过时的global.json文件会导致这个问题.但我在解决方案的任何地方都没有global.json文件.
我正在尝试将使用旧csproj格式定义的WPF项目迁移到VS 2017下的新格式.
使用我在如何将Wpf项目迁移到新的VS2017格式时发现的信息,我能够获得成功构建的大部分内容.
但是我坚持要克服这个错误:
错误CS5001:程序不包含适用于入口点的静态"主"方法
我的新式csproj文件如下:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
<OutputType>winexe</OutputType>
<TargetFramework>net47</TargetFramework>
<ApplicationIcon />
<OutputTypeEx>winexe</OutputTypeEx>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
<Compile Update="Properties\Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
<Compile Update="Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />
<None Update="Settings.settings" LastGenOutput="Settings.Designer.cs" Generator="SettingsSingleFileGenerator" />
<Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
<Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
<Resource Include="assets\*.*" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.6.0" />
<PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="4.0.0" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="3.0.0" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.0.8" />
<PackageReference Include="MaterialDesignColors" Version="1.1.3" />
<PackageReference …Run Code Online (Sandbox Code Playgroud) 我正在尝试在VS 2017中的MVC核心项目中设置gulp.我有我认为有效的gulpfile.js:
var gulp = require('gulp');
var rimraf = require('rimraf');
var concat = require('gulp-concat');
var cssmin = require('gulp-cssmin');
var uglify = require( 'gulp-uglify' );
var paths = {
webroot: './wwwroot/',
};
paths.js = paths.webroot + 'js/**/*.js';
paths.minJs = paths.webroot + 'js/**/*.min.js';
paths.css = paths.webroot + 'css/**/*.css';
paths.minCss = paths.webroot + 'css/**/*.min.css';
paths.concatJsDest = paths.webroot + "js/site.min.js";
paths.concatCssDest = paths.webroot + "css/site.min.css";
gulp.task("clean:js", function (cb) {
rimraf(paths.concatJsDest, cb);
});
gulp.task("clean:css", function (cb) {
rimraf(paths.concatCssDest, cb);
});
gulp.task( "clean", ["clean:js", "clean:css"] ); …Run Code Online (Sandbox Code Playgroud) 我无法从Azure密钥保管库访问密钥.我怀疑问题是我没有充分理解术语,所以我提供给各种API调用的参数是错误的.
这是我正在使用的基本代码:
protected async Task<string> GetCommunityKeyAsync( UserConfiguration user )
{
var client = new KeyVaultClient(
new KeyVaultClient.AuthenticationCallback( GetAccessTokenAsync ),
new HttpClient() );
// user.VaultUrl is the address of my key vault
// e.g., https://previously-created-vault.vault.azure.net
var secret = await client.GetSecretAsync( user.VaultUrl, "key-to-vault-created-in-azure-portal" );
return secret.Value;
}
private async Task<string> GetAccessTokenAsync( string authority, string resource, string scope )
{
var context = new AuthenticationContext( authority, TokenCache.DefaultShared );
// this line throws a "cannot identify user exception; see
// below for details
var …Run Code Online (Sandbox Code Playgroud) 我正在遇到一个关于未终止的Promise链的Promise警告('一个承诺是在一个处理程序中创建但是没有从它返回').我是Promises的新手,怀疑我不应该使用非事件驱动的思维.但我不知道该怎么办.这都在nodejs项目中.
我正在与ZWave服务器交互以打开和关闭灯.该交互采取以下形式:向控制ZWave网络的服务器发出http请求.我正在使用Promises,因为通过http进行交互的异步性质.
在我的程序的一个级别,我定义了以下类方法:
ZWave.prototype.onOff = function (nodeNumber, turnOn) {
var self = this;
var level = turnOn ? 255 : 0;
return new Promise(function (resolve, reject) {
self.requestAsync(sprintf('/Run/devices[%d].instances[0].commandClasses[0x20].Set(%d)', nodeNumber, level))
.then(function (value) {
resolve(value == 'null');
})
.catch(function (error) {
reject(error);
});
});
Run Code Online (Sandbox Code Playgroud)
};
requestAsync类方法实际上是处理与ZWave服务器交互的方法.从概念上讲,在onOff()中,我试图打开或关闭由this.nodeNumber标识的特定灯光,然后返回该请求的结果.
从Switch类方法调用onOff(),表示特定的灯光,如下所示:
this.onOff = function( turnOn ) {
var state = turnOn ? 'ON' : 'OFF';
var self = this;
zWave.onOff( this.nodeNumber, turnOn )
.then( function() {
winston.info( sprintf( '%s: turned %s', self.displayName, state ) ); …Run Code Online (Sandbox Code Playgroud) Find()方法接受一个对象数组,描述您尝试查找的主键.有关如何处理复合主键的文档不清楚.我尝试搜索github存储库,但无法找到Finder.Find()方法的源代码.
例如,我使用了流畅的API来定义以下复合主键:
modelBuilder.Entity<Article>()
.HasKey( x => new { x.CommunityID, x.ArticleID } );
Run Code Online (Sandbox Code Playgroud)
我这样调用Find():
Find( new object[] {1, 2} );
Run Code Online (Sandbox Code Playgroud)
或者像这样:
Find( new object[] { new {CommunityID = 1, ArticleID = 2} } );
Run Code Online (Sandbox Code Playgroud)
如果这是第一种方法,那么参数的顺序是否与Fluent API匿名对象上定义的属性顺序相同?
我正在和角度手表阵列一样摔跤.我有以下标记:
<map name="theMap" center="{{mapInfo.center.toUrlValue()}}" zoom="{{mapInfo.zoom}}" on-dragend="dragEnd()" on-zoom_changed="zoomChanged()">
<marker ng-repeat="pin in pins() track by pin.iconKey()" position="{{pin.latitude}}, {{pin.longitude}}" title="{{pin.streetAddress}}" pinindex="{{$index}}" on-click="click()"
icon="{{pin.icon()}}"></marker>
</map>
Run Code Online (Sandbox Code Playgroud)
pins()返回的每个引脚都有许多属性,子属性等.其中一个子属性控制标记颜色.当该子属性发生变化时,我希望UI更新.
因为ng-repeat似乎是基于对集合的简单更改来监视,所以如何实现这一目标并不明显.我认为我的跟踪功能iconKey()会这样做,因为它会根据子属性的值返回不同的值.但那没用.
另一件事:从一个在指令下运行的$ interval回调中,子属性发生了变化.我提到这一点是因为,在之前的帖子中,有人认为可能存在上下文/范围问题.
但是,即使我在UI控制器中的事件监听器中进行了更改(事件在$ interval回调的"success"子句中引发),它仍然不起作用.
这就是为什么我认为问题只是棱角分明没有注意到iconKey()的变化; 它的表现就像所有的$ ng手表一样,ng-repeat是数组的长度.当子属性发生变化时,这不会改变.
更新
我创造了一个能够展示我面临的问题的傻瓜.您可以在http://plnkr.co/edit/50idft4qaxqw1CduYkOd找到它
它是我正在构建的应用程序的缩减版本,但它包含基本元素(例如,用于保存有关地图引脚的信息的数据上下文服务以及用于切换其中一个引脚数组元素的子属性的$ interval服务) .
您可以通过单击菜单栏中的"开始"来开始更新周期(您可能需要稍微向下拖动地图以将两个引脚置于完整视图中).它应该切换每个引脚的颜色,或者每次5次,每2秒一次.它通过在控制器中定义的侦听器中切换pin对象的isDirty属性的值来实现.该事件由$ interval服务引发.
如果您在测试周期中在第22行中断,您将看到返回的图钉图标.因此,角度内的某些东西需要信息......但是引脚颜色不会改变.
我期待有人能够迅速指出与我的任何理论无关的骨头错误:).对于我穿的任何眼罩都要提前道歉.
更新2
在检查响应中的代码片段后,我简化了我的plnkr,并证明了角度实际上是在子属性发生变化时更新UI.所以这似乎是ng-map中的限制或错误.
我正在尝试使用EF Core工具来管理我在C#类库中设计的SqlServer数据库.它位于类库中,因为我需要在MVC6网站和一些命令行工具中使用数据库模式.
我不得不将类库转换为netapp,因为当前版本的工具不支持类库,但我不认为这是我的问题的根源.
我的DbContext类看起来像这样:
public class ConnellDbContext : IdentityDbContext<ConnellUser>
{
public ConnellDbContext( DbContextOptions<ConnellDbContext> options )
{
}
// core tables
public DbSet<Ballot> Ballots { get; set; }
public DbSet<Campaign> Campaigns { get; set; }
//...
}
Run Code Online (Sandbox Code Playgroud)
当我在程序包管理器控制台上运行"dotnet ef迁移列表"时,收到以下错误消息:
在'ConnellDbContext'上找不到无参数构造函数.要么将无参数构造函数添加到'ConnellDbContext',要么在与'ConnellDbContext'相同的程序集中添加'IDbContextFactory'的实现.
我不太清楚如何解决这个问题.插入无参数构造函数很容易,但是当我这样做时,我得到以下错误:
没有为此DbContext配置数据库提供程序.可以通过覆盖DbContext.OnConfiguring方法或在应用程序服务提供程序上使用AddDbContext来配置提供程序.如果使用AddDbContext,那么还要确保您的DbContext类型在其构造函数中接受DbContextOptions对象,并将其传递给DbContext的基础构造函数.
我>>想想<<这意味着控制台命令没有在我的appsettings.json文件中获取连接字符串信息:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-ConnellCampaigns;Trusted_Connection=True;MultipleActiveResultSets=true;AttachDbFilename=e:\\SqlServer\\Data\\ConnellCampaigns.mdf;"
}
}
Run Code Online (Sandbox Code Playgroud)
我遗漏了一些关于EF工具如何访问源代码以实现其魔力的东西.任何指针或线索都将非常感激.
附加信息
对安德森先生来说,我已经取得了一些进展.我添加了一个无参数构造函数并覆盖了我的DbContext类中的OnConfiguring()方法:
protected override void OnConfiguring( DbContextOptionsBuilder optionsBuilder )
{
var builder = new ConfigurationBuilder()
.AddJsonFile( "appsettings.json", optional: true, reloadOnChange: true );
IConfigurationRoot config = builder.Build();
optionsBuilder.UseSqlServer(config.GetConnectionString("DefaultConnection") );
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,但在UseSqlServer()的调用中明确包含实际的连接字符串.关于为什么基于"DefaultConnection"的呼叫不起作用的想法?
我正在MVC Core下的Web API调用中创建一个zip文件,但Windows无法打开生成的文件,声称它无效.
以下是创建存档的代码:
ZipArchive archive = new ZipArchive( archiveMS, ZipArchiveMode.Create, true );
// loop over a series of Azure blobs which contain text
foreach( BlobPathInfo curBPI in model.Paths )
{
// AzureBlobFile is a wrapper for CloudBlockBlob
AzureBlobFile blobFile = blobFolder.File( curBPI.BlobPath.FileName );
Stream blobStream = blobFile.OpenRead();
ZipArchiveEntry entry = archive.CreateEntry( zipFolderPath.ToString() );
using( Stream zipStream = entry.Open() )
{
blobStream.CopyTo( zipStream );
}
}
archive.Dispose();
archiveMS.Seek( 0, SeekOrigin.Begin );
return new FileStreamResult( archiveMS, "application/zip" );
Run Code Online (Sandbox Code Playgroud)
从角度脚本调用此WebAPI方法,并将其转换为链接到元素的客户端blob:
// downloadFiles …Run Code Online (Sandbox Code Playgroud) 我使用 IDesignTimeDbContextFactory<> 模式在单独的程序集中定义了一个 Entity Framework Core 数据库(即,我定义一个派生自 IDesignTimeDbContextFactory 的类,该类具有一个名为 CreateDbContext 的方法,该方法返回数据库上下文的实例)。
由于 EF Core 数据库所属的应用程序使用 AutoFac 依赖注入,因此 IDesignTimeDbContextFactory<> 工厂类在其构造函数中创建 AutoFac 容器,然后解析 DbContextOptionsBuilder<> 派生类,该类被馈送到数据库的构造函数中(我这样做是为了根据配置文件设置,控制是否将本地数据库或基于 Azure 的 SqlServer 数据库作为目标,并将密码存储在 Azure KeyVault 中):
public class TemporaryDbContextFactory : IDesignTimeDbContextFactory<FitchTrustContext>
{
private readonly FitchTrustDBOptions _dbOptions;
public TemporaryDbContextFactory()
{
// OMG, I would >>never<< have thought to do this to eliminate the default logging by this
// deeply-buried package. Thanx to Bruce Chen via
// /sf/ask/3358753611/#48016958
LoggerCallbackHandler.UseDefaultLogging = false;
var builder = new ContainerBuilder();
builder.RegisterModule<SerilogModule>();
builder.RegisterModule<KeyVaultModule>(); …Run Code Online (Sandbox Code Playgroud) c# ×4
angularjs ×1
asp.net-core ×1
azure ×1
entity-framework-core-migrations ×1
gulp ×1
javascript ×1
ng-map ×1
node.js ×1
promise ×1
wpf ×1