views:

243

answers:

2

Hi. I'm using the Entity Framework 4 and have a question:

I have a password column in my database that I want to manage using custom SQL. So I don't want the model to know anything about it.

I've tried deleting the property in the Mapping Details window, but then I got a compilation error:

Error 3023: Problem in mapping fragments starting at line 1660:Column User.Password in table User must be mapped: It has no default value and is not nullable.

So, I made the column nullable in the database and updated the model. Now I get this error:

Error 3004: Problem in mapping fragments starting at line 1660:No mapping specified for properties User.Password, User.Salt in Set Users. An Entity with Key (PK) will not round-trip when: Entity is type [UserDirectoryModel.User]

Any ideas please?

Thanks, Nick

+2  A: 

One way to fix this is to create a view of your user table that does not include the password column. Then use the view in your model rather than the table.

Shiraz Bhaiji
Thanks. That sounds workable.
Nick Butler
+1  A: 

You could just mark the Property as Private using the Properties pane in the EDMX designer: Under the code generation option it has Getter and Setter options that you can change from Public to Private.

Hightechrider
Thanks. That's the quick solution.
Nick Butler