开发者

How to create read-only entity in Entity Framework?

My app is purely read-only so I don't want to generate all the update & delete code, and I don't want to pull in all fields from all tables. Some of these fields are not nullable so I am getting errors from EF here becasue there is no default value to save.

In my previous ORM (Wilson) you could just flag an entity as read-only in the XML. I've seen a few posts showing convoluted solu开发者_Go百科tions to this. Am I missing something? Why isn't this straight forward?

I see that the RIA services wizard has a check box for this for each entity...


The problem is that you have a non-nullable field in your SSDL which isn't in your CSDL.

You can manually remove the column from SSDL and the EF will be happy. But the designer will re-add the column when you update the model. So you can either remove it again or update your model from a variant of the DB which doesn't have that column.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜