【发布时间】:2021-03-17 21:03:06
【问题描述】:
我使用以下代码从 Ajax 获取视图模型数据:
$.ajax({
url: '@Url.Action("Create", "Invoice")',
type: "POST",
contentType: 'application/json',
data: JSON.stringify(invoiceViewModel),
success: function (response) {
alert(response + " records inserted.")
},
error: function (response) {
alert(response + " records not inserted.")
}
});
然后我想将它插入到我的控制器中的 Create 操作中。
如何使用 Entity Framework Core 插入?
【问题讨论】:
-
How can I insert using Entity Framework Core?您是否创建了所需的模型类、数据库上下文类并使用依赖注入注册了您的数据库上下文?要开始在 ASP.NET MVC 中使用 EF Core,请查看此文档:docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/… -
嗨@Ager,有关于这个案例的最新消息吗?
标签: ajax entity-framework-core asp.net-core-mvc