Entity Framework - Merging 2 physical tables into one "virtual" table problems...
Posted
by Keith Barrows
on Stack Overflow
See other posts from Stack Overflow
or by Keith Barrows
Published on 2010-03-05T20:54:40Z
Indexed on
2010/03/18
13:31 UTC
Read the original article
Hit count: 482
I have been reading up on porting ASP.NET Membership Provider into .NET 3.5 using LINQ & Entities. However, the DB model that every single sample shows is the newer model while I've inherited a rather old model. Differences:
- The User Table is split into a pair of User & Membership Tables.
- All of the tables in the DB are prepended with aspnet_
- I have Lowered versions of some columns (UserName, Email, etc)
To work with this I have copied the properties from the Membership table into the User table (in the DB this is a 1<->1 relationship, not a 1<->0,1), renamed aspnet_Applications to Application, aspnet_Profiles to Profile, aspnet_Users to User and aspnet_Roles to Role. (See image)
Link to full size image of model
Now, I am running into one of 2 problems when I try to compile.
- Using the model in the image I get this error: Problem in Mapping Fragment starting at line 464: EntitySets 'UserSet' and 'aspnet_Membership' are both mapped to table 'aspnet_Membership'. Their Primary Keys may collide.
- If I delete the aspnet_Membership table from my model (to handle the above error) I then get: Problem in Mapping Fragment starting at line 384: Column aspnet_Membership.ApplicationId in table aspnet_Membership must be mapped: It has no default value and is not nullable.
My ability to hand edit the backing stores is not the best and I don't want to just hack something in that may break other things. I am looking for suggestions, best practices, etc to handle this.
Note: Moving the data tables themselves is not an option as I cannot replace all the logic in the existing apps. I am building this EF Provider for a new App. Over the next 6 months the old app(s) will migrate bit-by-bit to the new structures.
Note: I added a link just under the image to the full size image for better viewing.
© Stack Overflow or respective owner