EF4 0..1 relationship leads to Error 2016: Condition cannot be specified
This is very similar to a previous question (and may be the exact same question) but I really didn't understand the answers enough to be able to tell for sure.
I am using Entity Framework 4 in Visual Studio RC1 to create an azure service app (so it is .Net 3.5). I have a database with a lot of patterns like the following:
Thing ThingType
------------- --------------
Id : int Id : int
Type : int
where Thing.Type is referencing a ThingType. When EF4 assembles the model from the database, an error is generated which reads:
Error 开发者_运维技巧2016: Condition cannot be specified for Column member 'Type' because it is marked with a 'Computed' or 'Identity' StoreGeneratedPattern.
I'm at a loss as to how to move forward, but obviously this is a very common scenario. I feel very confident that somebody can help me out.
In RC1 there is a bug where the foregin key relationships keep getting marked as StoreGeneratedPattern="Identity"
. This may be causing the issue you are seeing here but I cannot say for sure since your environment is different. Take a look at your EDMX file, you should see the StoreGeneratedPattern="Identity" only the Id field for Thing and ThingType and not on the ThingThingType relationship.
See also http://blog.abodit.com/2010/03/system-data-updateexception-a-value-shared-across-entities-or-associations-is-generated-in-more-than-one-location-check-that-mapping-does-not-split-an-entitykey-to-multiple-store-generated-columns/
Microsoft has confirmed that this bug is fixed for RTM which is good since it affects you every time you update the model from the database!
精彩评论