문제

I'm using Model-First Entity Framework with an edmx file that has been "reverse engineered" from an existing database.

For the most part, the entities and navigation properties have been detected automatically based on my conventions, but there are some navigation properties missing - for example:

At the moment Works.EditorUserID is a foreign key to Users.UserID, but Entity Framework does not automatically include an Editor navigation property on the generated object.

Is there a better naming convention that I can use on my database that would allow this to happen?

Thanks

UPDATE: I have just realised that the navigation property is in fact being created, but it's name is not very useful - it is creating a navigation property called User instead of Editor.

도움이 되었습니까?

해결책

Navigation properties are automatically given the name of the related table when generating the model from an exiting database (also called "Database First"). EF does not attempt to extract additional "metadata" from foreign key column names to determine a more appropriate name for the navigation property.

If you're not satisfied with the given name, simply change it in the model.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top