缺少 MVC 实体类型

发布于 2024-10-07 14:44:56 字数 784 浏览 1 评论 0原文

我是 ASP.NET MVC 的新手(实际上只是动态学习了两天)。我正在尝试使用 MVC 创建一个网站,但是,我的解决方案搞砸了一些东西。

我创建了这个具有外键约束的表,但我最初忘记在 id 字段上设置主键,并且忘记将其身份规范设置为 yes。因此,当我更新数据模型并引入该表时,它显示每个字段都是主键,并且显示与其他表的关系。所以我回到数据库,将表的id字段更改为主键,并将身份规范更改为yes。

我回到 DataModel,尝试从数据库更新模型,转到刷新选项卡,展开表,然后选择我要刷新的表,然后单击“完成”。

数据模型似乎进行了更改,但它两次显示了与其他表的关系。

所以我想我应该从 DataModel 图中删除表(实体),并通过从数据库更新模型将表带回。但是,当我返回到“从数据库更新模型”时...

  1. 在“添加”选项卡下,该表不在
  2. “刷新”选项卡下的“表”下,该表已列出,但是当我选择它并单击“完成”该表时不再出现在图中。

在模型浏览器中... 在模型

  • 实体类型下,实体未
  • 在关联下列出,关系不再出现(显然是因为实体已消失)。

在 Models.Store

  • Tables/Views 下,列出了该表。
  • 显示约束、关系。

我尝试将表格从模型浏览器拖到图表上,但这似乎不起作用。

我尝试右键单击图表,添加实体,但我的表没有显示为基本类型。

我尝试用谷歌搜索,但一无所获。如果缺少这个实体,我什至无法构建我的解决方案。请帮忙。

I'm brand new to ASP.NET MVC (Literally just two days of learning on the fly). I'm trying to create a website using MVC, however, I've screwed something up in my solution.

I created this table that had foreign key constraints but I initially forgot to set up a primary key on the id field and forgot to set it identity specification to yes. So when I updated my DataModel and brought this table in, it showed every field as being the primary key and it showed the relationship to the other tables. So I went back to the database and changed the id field for the table to be the primary key and identity specification to yes.

I went back to the DataModel, tried to Update Model From Database, went to the refresh tab, expanded the tables, and selected the table I wanted to refresh, then click on "Finish".

The data model appeared to make the changes but it showed the relationships to the other tables twice.

So I thought I'd delete the table (entity) from the DataModel diagrahm and bring the table back in through Update Model From Database. But when I went back to the Update Model From Database...

  1. Under the Add tab, the table isn't under the Tables
  2. Under the Refresh tab, the table is listed, but when I select it and click on "Finish" the table doesn't reaapear in the diagrahm.

In the model browser...
Under Models

  • Entity Types, The entity isn't listed
  • Under Associations, The relationships no longer appear (obviously because the entity is gone).

Under Models.Store

  • Tables/Views, The table is listed.
  • Constraints, the relationships are shown.

I've tried dragging the table over to the diagrahm from the Model Browser, but that doesn't appear to work.

I've tried to right click in the diagrahm, add Entity but my table doesn't appear as a Base Type.

I've tried to google but I'm coming up with nothing. With this entity missing, I cannot even build my solution. Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深居我梦 2024-10-14 14:44:56

尝试删除实体文件并重新添加。但您必须将其命名为先前的实体,并且在添加之前不要忘记删除 web.config 中的connectionString。

如果您不知道我在说什么,请告诉我。

Try to delete the entity file and add it again. But you have to name it as previous entity and don't forget to delete the connectionString in web.config before add it.

If you don't know what I am saying just let me know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文