Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MVC - Model (EDMX) Is there a way to prevent data update to database?

Status
Not open for further replies.

fletchsod

Programmer
Dec 16, 2002
181
I have created an EDMX layout (Generate from Database) in Visual Studio 2010.

I have a problem, it have too many fields, I only need 4 fields in the EDMX. Can it be done?

I have another problem, this layout would allow updating of the data to the database which I don't want. How to prevent that from occuring in source code?

Thanks...
 
I have a problem, it have too many fields, I only need 4 fields in the EDMX. Can it be done?
what you describe is called a projection (at least in NH terms). you are looking for a read-only view of some portion of your domain model to display to the user. I would think that's possible with EF. I would start by googling "EF projections".

I have another problem, this layout would allow updating of the data to the database which I don't want.
are you using code gen to create the UI? if so you will either need to
1. adjust the generated code after it's produced.
2. create the UI your self instead of using code gen.

there may be an option to generate the UI as read-only, but the more you depend on other tools to write your code the less control you have.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top