将列添加到数据库dbml文件linq时出现此错误

I have this error when add column to database dbml file linq

提问人:Hoàng 提问时间:11/15/2023 更新时间:11/15/2023 访问量:27

问:

这是我在 asp.net mvc core 5 中的 dbml 文件enter image description here

当我尝试为修改后的表创建一个新实体,然后将新属性从新实体拖/剪切到旧实体时,我在控制器中出现此错误

“dbQLBansachDataContext”不包含接受 0 个参数的构造函数

如何修复此错误?

asp.net LINQ 控制器

评论

0赞 Svyatoslav Danyliv 11/15/2023
添加不带参数的构造函数?

答:

0赞 Eduardo Santos 11/15/2023 #1

新版本的 Visual Studio 不会在文件(在 DBML ...___designer.cs > dbQLBansachDataContext.designer.cs 中)包含空构造函数。您需要添加它。

公共 dbQLBansachDataContext() :

    base(global::System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString, mappingSource)
  {
      OnCreated();
  }