在EF4中创建表和视图之间的一对一关系? [英] Create One-To-One relationship between table and view in EF4?

查看:152
本文介绍了在EF4中创建表和视图之间的一对一关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表项(ItemId int PK,Title vc,Description vc)



我创建了一个名为ItemView的测试视图:SELECT * FROM Item。



我将这个视图添加到我的模型中,删除了所有的键,但是真正的键,添加了一个1-1关联,并将其映射,但是我收到2个错误:


  1. 表/视图'dbo.ItemView'没有定义主键。该关键字被推断,并且定义被创建为只读表/视图。

  2. 错误3021:映射从第xxxx行开始的片段中的问题:表项中的以下各列映射到多个概念侧属性:
    Item.ItemId映射到
    有什么问题?


解决方案

Edmx Views处理器 - 此问题的修补程序。


I have a table Item (ItemId int PK, Title vc, Description vc)

I created a testing view called ItemView: SELECT * FROM Item.

I added this view to my model, removed all the keys but the real key, added a 1-1 association, and mapped it, but I get 2 errors:

  1. The table/view 'dbo.ItemView' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
  2. Error 3021: Problem in mapping fragments starting at line xxxx: Each of the following columns in table Item is mapped to multiple conceptual side properties: Item.ItemId is mapped to What can be the problem?

解决方案

Edmx Views Processor - a hotfix for this issue.

这篇关于在EF4中创建表和视图之间的一对一关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆