NOTE: VS2010 / .NET 4, but without a beta version of SP1 at the moment, but if something in SP1 addresses this, it would still be great to know. :)
I have a specific database from which I want to read, but never write. I do not see anything in the properties of the model (looking in the EF designer) to mark it as read-only.
Of course, it seems that the easiest way is to add an incomplete class for the generated ObjectContext subclass (FooModel: ObjectContext class) to override SaveChanges (SaveOptions) and make it quit (maybe connecting to SavingChanges and throwing will work too, I haven't even tried). This will not disable change tracking, and AFAICT I will have to iterate over all entity sets when creating a context instance to mark them read-only (although this problem is not so critical, t persist).
Of course, there are other parameters, such as connecting the connection string as a user with read-only access, but I wonder what parameters are available from the point of view of the designer / model / EF instance for read-only object contexts?
source
share