1. The poco class must be passed by WCF and cannot be referenced cyclically (you can add [datacontract (isreference = true)] to the object class)
2. One problem is the delayed loading of EF and the proxy instance mechanism. As a result, the EF query result is not a poco class, but a proxy class,
EF proxy instance mode: configuration. proxycreationenabled = false;
How to Implement the updateuser method is usually updated using the idbset. Attach () method.
M_dbset.attach (entity );
This. dbcontext. Entry <t> (Entity). State = entitystate. modified;
This. dbcontext. savechanges ();
However, you will find that, because EF has disabled proxycreationenabled to support the WCF Service, the attach method here cannot be executed successfully in any case,
At this time, you will think, I will not use the attach method, delete the object first, and then re-Add the row,
No no. Because EF automatically modifies the data table based on the object relationship during savechanges, When you delete a user, the records in the User table and user_role table will be deleted, if the user object is added, the user and user_role tables will be added to the user table, and the role table will be added to the role table (because the user. roles ),
At this time, you will find that adding a role to the role table will not work, because the record already exists; so this method cannot solve the problem well !!
What should I do? I don't know what to do for the moment, so I am here to ask for help ~~ Let's see what experience we have and how to deal with it!
PS: Data Services and RIA services are not considered for the moment, because my application needs to authorize specific operations! Non-web System!