我有亲子关系(一对多).我能够创建子项,但删除失败.我创建了一个孩子,保存它,但是当我删除时,我得到:
A foreign key value cannot be inserted because a corresponding primary key value
does not exist. [ Foreign key constraint name = FK_dbo.Children_dbo.Parents_ParentId ]
Run Code Online (Sandbox Code Playgroud)
我注意到当删除被发送到服务器时,孩子的parentid为0,实体状态为"modified".我希望这会被"删除".
相关视图模型部分:
function queryFailed(error) {
console.log('Query failed: ' + error.message);
}
function save() {
dataservice.saveChanges().fail(queryFailed);
}
function deleteChild(child) {
parent().children.remove(child);
}
function addChild() {
dataservice.createChild(parent);
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<section data-bind="with: parent">
<div data-bind="foreach: children">
<div>
<select name="propertyOne"
data-bind="options: propertyOneOptions, value: propertyOne, optionsText: 'description', optionsCaption: 'Select a Property'">
</select>
<button data-bind="click: $root.deleteChild">Delete Child</button>
</div>
</div>
<button data-bind="click: …Run Code Online (Sandbox Code Playgroud) 首先我读了很多关于这个主题的文章,并安装了几个"路由调试"插件.我对Java/Spring比较熟悉,所以我真的不知道如何调试这个东西,使用vs 2012.(我无论如何都不能让IISExpress打印任何调试,而不是我习惯使用Spring/Tomcat的那种调试输出.)
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Legal",
action = "Index",
id = UrlParameter.Optional }
);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我可以通过默认控制器点击索引页面.但是,我试图基于以下控制器点击URL/WebApi/Metadata /:
[BreezeController]
public class WebApiController : ApiController {
private readonly EFContextProvider<BankruptcyDbContext> _contextProvider =
new EFContextProvider<BankruptcyDbContext>();
[HttpGet]
public string Metadata() {
return _contextProvider.Metadata();
}
}
Run Code Online (Sandbox Code Playgroud)
"Route Debugger"表示我对/ WebApi/Metadata,/ WebApi/Metadata /,/ WebApi/Metadata/0等的请求应该"匹配",但我得到的只是404.
Edit1:我终于找到了跟踪日志并获得了更多细节:
The controller for path &#39;/WebApi/Metadata&#39; was not found or does not implement IController
Run Code Online (Sandbox Code Playgroud)