开发者

SQL Server foreign keys messing with entity framework model

I have an entity framework model, and I noticed that one table, a usergroup table is missing from the diagrams in th开发者_开发百科e model file. This meant I could not modify it from the standard SQL calls to become part of the entity framework (i.e., to make a class file for it with entities).

I can see it under "entity sets" but not in the diagram. Every time I try to add, it doesn't show it as an option to add in the "update model" menu. So I deleted it from Entity set, and then I finally saw it in 'update model'. I added it. Still won't show up on diagram (it just puts it as Entity Set, but doesn't make a diagram for it).

After getting frustrated with it, I figured there was some foreign keys preventing it from being added. So I went to my sql manager, and deleted any foreign key from usergroup table.

So now, when I add in the model, it appears in the diagram! YES!

BUT, now compiler error 3002 saying models don't match. "Potential runtime violation of table" saying the mapping is incorrect, but I don't understand---there is no mapping there, there is nothing linking usergroup to anything.

Why is this happening? I checked other foreign keys and mapping properties and nothing maps to usergroup. Is it a bug in Visual Studio 2010?


It is probably that the sections of the edmx file are out of sync or maybe parts are corrupt.

You could try opening the edmx file in a text editor and check for any errors.

You could also try removing that table, then opening the edmx file in a text editor and make sure that all references to that table have been removed.

The mapping error is not between tables, it is between parts of the edmx file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜