当我PM> Remove-Migration -context BloggingContext
使用EF Core在VS2015中运行ASP.NET Core项目时,我收到以下错误:
System.InvalidOperationException: The migration '20160703192724_MyFirstMigration' has already been applied to the database. Unapply it and try again. If the migration has been applied to other databases, consider reverting its changes using a new migration. at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.RemoveMigration(String projectDir, String rootNamespace, Boolean force)
at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.RemoveMigration(String contextType, Boolean force)
at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsRemoveCommand.<>c__DisplayClass0_0.<Configure>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
The migration '20160703192724_MyFirstMigration' has already been applied to the database. Unapply it and try again. If the migration has …
Run Code Online (Sandbox Code Playgroud) c# entity-framework-core visual-studio-2015 .net-core asp.net-core
问题:price = co?.price ?? 0,
以下代码中的行给出了上述错误.但如果我?
从co.?
它删除它工作正常.我试图按照此MSDN例如,他们使用的是?
上线select new { person.FirstName, PetName = subpet?.Name ?? String.Empty };
所以,看来我需要了解什么时候使用?
与??
和何时不.
错误:
表达式树lambda可能不包含空传播运算符
public class CustomerOrdersModelView
{
public string CustomerID { get; set; }
public int FY { get; set; }
public float? price { get; set; }
....
....
}
public async Task<IActionResult> ProductAnnualReport(string rpt)
{
var qry = from c in _context.Customers
join ord in _context.Orders
on …
Run Code Online (Sandbox Code Playgroud) 在我们的ASP.NET MVC 4 Web应用程序中,我们的BundleConfig.cs包括以下内容:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
Run Code Online (Sandbox Code Playgroud)
当我们查看开发服务器上主页的html时,即使web.config中的调试模式设置为true,我们也可以看到以下脚本标记<compilation debug="true" targetFramework="4.0" />
:
<script src="/AFR/Scripts/jquery-ui-1.8.20.min.js"></script>
<script src="/AFR/Scripts/modernizr-2.5.3.js"></script>
<script src="/AFR/Scripts/jquery-1.7.1.js"></script>
<script src="/AFR/Scripts/jquery-ui-1.8.20.js"></script>
<script src="/AFR/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/AFR/Scripts/jquery.validate.js"></script>
<script src="/AFR/Scripts/jquery.validate.unobtrusive.js"></script>
Run Code Online (Sandbox Code Playgroud)
但是当我们在登台服务器上部署应用程序并查看主页的html(查看源代码)时,除了<script src="/AFR/Scripts/jquery-ui-1.8.20.min.js"></script>
缺少所有上述脚本标记.我们已经验证了这些标记中提到的所有文件都在脚本文件夹中.文件夹结构与开发机器上的完全相同.在登台服务器上,web.config fie具有<compilation targetFramework="4.0" />
默认情况下debug ="false"的含义.
因此,某些JavaScript函数在登台服务器上失败.登台和开发机器都是Windows 2012.
请帮忙.谢谢.
我正在使用这个MSDN教程在VS2015 PM> Add-Migration MyFirstMigration -context BloggingContext
中运行昨天成功运行的命令,但今天它给出了以下错误,这也是其他用户在这里指出的.我甚至从解决方案资源管理器中删除了Migrations文件夹,并从SQL Express 2014 on Win 8.1
相同的错误中删除了相应的数据库 即使我跑,Add-Migration MyFirstMigration
我得到同样的错误:
Add-Migration : The term 'Add-Migration' 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
+ Add-Migration MyFirstMigration -context BloggingContext
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException …
Run Code Online (Sandbox Code Playgroud) 在我的ASP.NET核心(.NET Framework)项目中,我在以下的Controller Action方法中遇到了错误.我可能缺少什么?或者,有什么工作吗?:
public class ClientController : Controller
{
public ActionResult CountryLookup()
{
var countries = new List<SearchTypeAheadEntity>
{
new SearchTypeAheadEntity {ShortCode = "US", Name = "United States"},
new SearchTypeAheadEntity {ShortCode = "CA", Name = "Canada}
};
return Json(countries, JsonRequestBehavior.AllowGet);
}
}
Run Code Online (Sandbox Code Playgroud)
更新:
请注意以下@NateBarbettini的评论:
JsonRequestBehavior
已在ASP.NET Core 1.0中弃用.return type
action方法does not
特别需要是JsonResult类型.ActionResult或IActionResult也可以.我们在Windows 7上安装了Visual Studio 2015 Professional.它工作正常.但是,在我们今天从菜单工具 - >'扩展和更新'安装更新后,Visual Studio不再启动了.我们也尝试使用"以管理员身份运行".从"开始"菜单中,我们右键单击"Visual Studio 2015",然后"以管理员身份运行",出现询问权限的常用对话框,单击"是",Visual Studio的启动画面出现一秒钟然后消失.在任务管理器上,它也不会出现.
重新启动系统也无济于事.安装了.NET 4.6,同一系统上的Visual Studio 2012工作正常.
更新1 问题在我们安装上次更新后(从VS2015内部)开始,这与我认为的通用应用程序有关.
更新2 在我启动VS2015的确切时间,在安全部分下生成一个Windows事件日志,如下所示:
EventID 6281
Microsoft-Windows-Security-Auditing
Audit Failure
Message: Code Integrity determined that the page hashes of an image file are not valid.
The file could be improperly signed without page hashes or corrupt due to unauthorized modification.
The invalid hashes could indicate a potential disk device error.
File Name: \Device\HarddiskVolume3\Windows\System32\l3codeca.acm
Run Code Online (Sandbox Code Playgroud) 在我从同一教程创建的VS2015项目中运行该命令后,遵循此MicrosoftPM> Add-Migration MyFirstMigration
教程我得到以下错误,我无法解决:
More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands.
Run Code Online (Sandbox Code Playgroud)
要点注意
Individual User Account
身份验证而不是No Authentication
在教程中使用.ASP.NeT Core 1.0 and VS2015-Update 3 on windows 8.1
我按照这篇文章将我的ASP.NET MVC Core 1.0应用程序部署到使用IIS 10的Windows 10上的本地IIS.应用程序已成功部署并打开主页.我正在使用个人用户帐户身份验证.在主页上输入登录名/密码并单击" 登录"按钮时,出现以下错误.我正在使用最新版本的ASP.NET Core和VS2015.我使用VS2015发布向导来发布应用程序.一切都在同一台机器上完成:
处理您的请求时发生错误.
发展模式
交换到开发环境将显示有关发生的错误的更详细信息.
不应在已部署的应用程序中启用开发环境,因为它可能导致向最终用户显示异常的敏感信息.对于本地调试,可以通过将ASPNETCORE_ENVIRONMENT环境变量设置为Development并重新启动应用程序来启用开发环境.
在我的ASP.NET MVC 4应用程序中,我有一个索引视图,其中嵌入了几个部分视图.我通过NuGet安装了Rotativa的最新版本1.6.1.现在我可以使用Rotativa将索引页打印到PDF.我想在每个局部视图后在PDF中有一个分页符.如何使用Rotativa实现这一目标?
与以前版本的Entity Framework一样,Entity Framework Core中是否可以仅对现有数据库的选定表进行反向工程,以便从中创建模型类.这个官方的ASP.NET站点反向设计整个数据库.过去,如本ASP.NET教程所示,如果您选择使用旧的EF,您只能对所选的表/视图进行反向工程.
asp.net-mvc entity-framework asp.net-mvc-scaffolding visual-studio-2015 asp.net-core
asp.net-core ×6
c# ×4
asp.net-mvc ×2
.net-core ×1
asp.net ×1
iis ×1
javascript ×1
json ×1
linq ×1
pdf ×1
rotativa ×1
windows-7 ×1