I have a database like the following example:
Customer
CustomerID int
Name...
Document
DocumentID int
CustomerID int
DocumentDate...
Here's the thing. Not all documents are related to a customer. The problem is that this old database doesn't use an int NULL for Document->CustomerID. Instead, it's a nonnullable int, and it uses a stored value of -1 to indicate that it doesn't have a customer. The code that runs on top of this database knows that -1 is special, and indicates no related entity.
My problem is that now I want to build an entity model on top of it. Is there a way to tell the Entity Model that a -1 in the CustomerID field on the Document table means there is no relationship? Entity Framework would have to map the int at the database layer to a nullable int at the model layer, and whenever it retrieved a record from the db, it would have to map the value of -1 to a null, and whenever it saved, save a null as a -1. And when populating entitysets, this mapping would have to be factored in as well.
Does this make sense? It seems like something that Entity Framework might have built in under the covers somewhere, but then again, maybe not.
Ideas?