How to create read-only object in Entity Framework?

My application is purely read, so I donโ€™t want to generate all the update and deletion code, and I donโ€™t want to extract all the fields from all the tables. Some of these fields are not NULL, so I get errors from EF here because there is no default value to save.

In my previous ORM (Wilson), you can simply mark an object as read-only in XML. I saw several posts that presented complex solutions. Am I missing something? Why is this not so straightforward?

I see that the RIA Services Wizard has a checkbox for each object ...

Thanks for any explanation.

+7
source share
1 answer

The problem is that you have a non-NULL field in your SSDL that is not in your CSDL.

You can manually remove the column from the SSDL, and EF will be happy. But the designer will update the column when updating the model. Thus, you can either delete it again, or update your model from a database variant that does not have this column.

+1
source

All Articles