8

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

Nick Butler
  • 24,045
  • 4
  • 49
  • 70

2 Answers2

12

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.

Ian Mercer
  • 38,490
  • 8
  • 97
  • 133
5

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
  • 64,065
  • 34
  • 143
  • 252