Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
862 views
in Technique[技术] by (71.8m points)

.net 4.0 - EF4 complex type with navigation property (is it possible) or alternatives?

I hit the wall with doing EF4 Model with DB first approach using Linq-to-Entities with POCO...

I have two tables: Customer and NamePrefix that are related via NamePrefixId. Columns are:

Customer             NamePrefix
----------           ----------
CustomerId (PK)      NamePrefixId (PK)
NamePrefixId (FK)
LastName
FirstName
MiddleInitial
....

In this instance the Customer entity has a navigational property NamePrefix. I created a complex type NameOfPerson, so that I can use it in other entities. The complex type consists of NamePrefixId, LastName, FirstName, MiddleInitial. But now I am getting the following error message on the navigational property to NamePrefix:

Error 111: There is no property with name 'NamePrefixId' defined in type referred by Role 'Customer'.

Is there a way to accomplish this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is described directly in Complex type help page. Complex types cannot contain navigation properties.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...