hypnomaki
hypnomaki

Reputation: 662

Aspnet Entity Data Model wont work as expected

To start with I'm really new into developing with C#, ASPNET, and MS SQL so perhaps I'm just missing a simple point here or missunterstood a basic concept so please have patience with me :)

I'm Using Visual Studio Web Deveoloper 2010 Express with .NET Framework 4 and MVC2 (Have to use this specific Version). I also have SQL Management Studio 10.5 where I created a simple Table enter image description here

Now I want to use this as an entity model so I created one in Visual Studio and added all Tables (including the ASPNET User Tables) and Stored Procedures.enter image description here

The Problem is the Result...

enter image description here

I expected to be able to navigate from Kunden(createdBy, modifiedBy) to the ASPNET User Table like i can access "Geschenk" from the "Kunden" Table. I thought I will have a single Property here and not 2 of them for the same reason. Of course I could just rename the Navigation Properties but I want to know whats the cause of this and whats the proper way to use aspnetusers in this case?

Upvotes: 0

Views: 48

Answers (1)

smartcaveman
smartcaveman

Reputation: 42276

Kunden has 2 FK references to the aspnet_Users table. One corresponds to the createdBy column and the other corresponds to the modifiedBy column. Consequently, a navigation property is generated for each. Imagine that different users had created and modified a single Kunden.

If only a single association were generated, which user would you expect the aspnet_Users association to retrieve? If you're expecting a collection of both, then how would you distinguish between the two?

Upvotes: 1

Related Questions