根据MS Docs,Scaffold-DbContext应该接受一个可选参数-Namespace。不过,似乎Scaffold-DbContext无法识别这个参数。我错过了什么?
命令错误:
Scaffold-DbContext "Server=.\SQLExpress;Database=Stock;Trusted_Connection=True;User Id=sa;Password=P@ssw0rd;" Microsoft.EntityFrameworkCore.SqlServer -Namespace Stock.Models.DTO
Scaffold-DbContext : A parameter cannot be found that matches parameter name 'Namespace'.
At line:1 char:151
+ ... P@ssw0rd;" Microsoft.EntityFrameworkCore.SqlServer -Namespace Stock.M ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Scaffold-DbContext], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Scaffold-DbContext
Run Code Online (Sandbox Code Playgroud)
安装的软件包:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.4"> …Run Code Online (Sandbox Code Playgroud) 我已经开始学习如何将CakePHP框架用于兼职工作.我决定在这个框架中构建我的一个个人项目,以便对其进行一些练习.
我有一些我使用Cake bake命令创建的模型,我添加了自动CRUD支持(它为控制器添加var $scaffold了所有相关操作.我想编辑这些操作但我没有引用生成的代码.(正如我之前所说,它将脚手架成员添加到控制器,就是这样.)如何编辑这些操作?
我想用希伯来语构建我的应用程序,我需要将所有生成的错误消息和状态更改为希伯来语(也是脚手架中生成的那些).我怎么能做到这一点?
我只想弄清楚我的方式,但我需要一点帮助rails generate scaffold命令.
这是我想要使用的命令
rails generate scaffold Expense user:??? name:string description:text
Run Code Online (Sandbox Code Playgroud)
我希望该description字段可以为空,并将users字段链接到另一个模型 - 在这种情况下,我想为用户创建一个外键.我正在使用devise身份验证框架.
我已经读过许多RoR开发人员尝试避免使用脚手架方法而选择手动方法,但我的网络应用程序非常简单,我想到了脚手架方式.
我正在使用EF代码和mvc脚手架开发mvc3.0应用程序.我目前坚持实体之间的多对多关系.我有以下模型.
命名空间BigApp.Models {
#region POCO Objects
public class Group
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime UpdatedOn { get; set; }
public virtual ICollection<Project> Projects { get; set; }
}
public class Project
{
public int Id { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public DateTime CreatedOn { get; set; }
public …Run Code Online (Sandbox Code Playgroud) 我有两个模型:分类和图片分别引用两个表,分类和图片.Category模型具有Picture模型的导航属性.
现在,我使用Scaffolding功能创建了一个控制器,其中包含类别的CRUD操作.以下是代码: -
public ActionResult Create()
{
ViewBag.ParentCategoryId = new SelectList(db.Categories, "Id", "Name");
ViewBag.PictureId = new SelectList(db.Pictures, "Id", "PictureUrl");
return View();
}
Run Code Online (Sandbox Code Playgroud)
自动生成的控制器操作使用SelectList列出数据库中的可用图片条目,并将其传递到下拉列表以供选择.这不是理想的情况,因为我想要的是无法用户上传图片,然后将引用添加到类别模型.之后,条目将保存到"类别和图片"表中.
我按照http://guides.rubyonrails.org/getting_started.html上的教程使用脚手架并添加了rspec.到目前为止我没有添加任何特殊代码.
什么时候......
rake spec
Run Code Online (Sandbox Code Playgroud)
...我收到以下20个警告:
弃用警告:ActiveSupport :: Concern中的InstanceMethods模块将不再自动包含在内.请直接在RSpec :: Rails :: ViewExampleGroup中定义实例方法.(来自/Users/pixtur/Projects/website-com/spec/views/welcome/index.html.haml_spec.rb:3)
我不明白,这个错误试图告诉我什么.index.html.haml_spec.rb是由脚手架创建的,看起来像这样:
require 'spec_helper'
describe "welcome/index.html.haml" do
pending "add some examples to (or delete) #{__FILE__}"
end
Run Code Online (Sandbox Code Playgroud)
我正在使用 rails 3.2.3 / ruby 1.9.2
我必须遵循安装的宝石:
动作制作者(3.2.3)
actionpack(3.2.3)
我正在尝试在遗留数据库之上构建grails(2.1.0)应用程序.它有很多桌子,我非常喜欢只使用动态脚手架.问题是某些表有一个字符串作为主键,但src/templates/scaffolding/Controller.groovy中的模板代码例如show是
def show(Long id) {
def ${propertyName} = ${className}.get(id)
if (!${propertyName}) {
flash.message = message(code: 'default.not.found.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), id])
redirect(action: "list")
return
}
[${propertyName}: ${propertyName}]
}
Run Code Online (Sandbox Code Playgroud)
对于字符串键,这似乎将字符串转换为null,并且get因错误而失败$Domain not found with id null.
如果我运行生成控制器并将签名更改为def show(String id),它将按预期工作.
那么,有没有办法在"动态脚手架时间"检查域类并相应地编写方法?
例如,我想生成一个默认为布尔字段的脚手架 false
我有以下模型:
public class Promotion : BaseModel
{
[Required]
public string Description { get; set; }
[Required]
public string Market { get; set; }
[Required]
public double Price { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
它已创建一个已更新到数据库的迁移。并且一些促销已插入数据库中。但是我需要将促销模型更改为:
public class Promotion : BaseModel
{
[Required]
public string Description { get; set; }
[Required]
public Market Market { get; set; }
[Required]
public double Price { get; set; }
}
public class Market : BaseModel
{
[Required]
public string Name { get; set; } …Run Code Online (Sandbox Code Playgroud) scaffolding ×10
grails ×2
.net-core ×1
asp.net-core ×1
c# ×1
cakephp ×1
crud ×1
ef-core-3.0 ×1
many-to-many ×1
php ×1
razor ×1
rspec ×1
ruby ×1
upload ×1