数据库中有3表Person、Student、Worker。代码如下:

Code

 

现在在VS里建个ADO.NET Entity Data Model,就叫默认的Model1.edmx好了,操作如下:

1、建立Model1.edmx时,在数据库中只选择Person表,完成Model1.edmx

2、编译,通过

3、现在从数据库中更新,把Student和Worker都添加进来,这是会看到设计器自动把实体和关系都一并生成出来,还算蛮聪明的

4、编译,还是通过

5、Bug开始来了,把Student和Worker实体删除

6、编译,出错,我在中文版和英文版都试过(打正式sp1的,team system),错误如下:

Error    1    Error 3013: Problem in Mapping Fragment starting at line 144: Missing table mapping: Foreign key constraint 'FK_Student_Person' from table Student (PersonID_FK) to table Person (PersonID): no mapping specified for the table Student.
Error    2    Error 3013: Problem in Mapping Fragment starting at line 144: Missing table mapping: Foreign key constraint 'FK_Worker_Person' from table Worker (PersonID_FK) to table Person (PersonID): no mapping specified for the table Worker.

 

按照微软讲师王然在webcast的说法,EF有时没有自动把后台代码删除完整,当时那webcast演示也是出错所以终止的。但他说是因为他的是beta版的原因。但我这几天测试了N次,发现在sp1正式版也出现这情况……郁闷

 

大家也出现过这现象吗?

posted on 2008-08-30 12:04  Dreaming  阅读(1018)  评论(0编辑  收藏  举报