I have 3 entities: BaseUser, AuthenticationUser and User. AuthenticationUser inherit from BaseUser and User inherit from AuthenticationUser. User entity has scalar property of type Binary (photo) so I would like to split the User entity into User and UserPhoto.
I did exactly what this nice article sais: http://www.deveducate.com/blog/post/2010/12/14/Entity-Framework-Modeling-Table-Splitting.aspx
Here is an image of my edmx:
When I validate the edmx I keep getting this error:
Error 3033: Problem in mapping fragments starting at line 13058:EntitySets 'UserPhotoes' and 'BaseUsers' are both mapped to table 'T_USER'. Their primary keys may collide.
What is the meanning of this error?
Any idea how to fix this?
Related
This is my table ( part of the whole thing , activity table still have other relationships with other tables) :
After adding foreign key and update my model EDMX from database in my visual studio , it came up this 2 error :
Error 2 Error 112: The types of all properties in the Dependent Role
of a referential constraint must be the same as the corresponding
property types in the Principal Role. The type of property
'ActivityID' on entity 'istellarModel1.singalong' does not match the
type of property 'ActivityID' on entity 'istellarModel1.activity' in
the referential constraint
'FK_singalong_activity'.
and
Error 1 Error 113: Multiplicity is not valid in Role 'activity' in
relationship 'FK_singalong_activity'. Because all the properties in
the Dependent Role are nullable, multiplicity of the Principal Role
must be '0..1'.
I checked my ActivityID in singalong have the same type as activity table's Activity ID , and i don't understand what error 113 actually means , i am new to database , at first i have many tables that don't link so i link them up after sometime and update my model ( EDMX ) in visual studio ( using entity framework ) and it gave me errors .
Any guidance on this please?
The 113 error sounds like your activity ID in singalong is NULLable.
It's stating that many-to-one is not valid if the dependent role is nullable.
That also seems to suggest the reason for the 112 - it's most likely complaining because it considers NOT NULL part of the type as well, so the two columns are different.
A quick fix may be to ensure that singalong.ActivityID is marked a NOT NULL but this will be problematic if you want singalong records with no corresponding activity.
I know how I'd fix it, at least initially, but it may be frowned upon be more knowledgeable DBAs: I'd simply add a dummy activity (eg, activity id = 0) to use for those cases where you would normally have NULL in the singalong table. I'm not suggesting you do that, but it's a possibility I would examine as a temporary fix, being far more of a pragmatist than dogmatist :-)
I know this is a old question, but run into the same issue, and here is the fix.
If you open your .edmx file (using entity framework), you will see your different tables. If you click on the line linking the tables:
It will show the properties. Select Multiplicity and set to 0..1
Your foreign key will need to be set as nullable.
OK, this is an interesting and most importably real urgent problem for me to solve... In order for others to neatly comprehend it, I've stretched myself to make a well illustrated post.
The Object Model
So I have this simple, easy and "beautiful" model in mind. See the first picture. (You can ignore PathEntry, it's not relevant in my situation.)
The idea is that a MediaFeedItem owns:
a collection of ThumbnailFileEntries (accesible through the ThumbnailFiles property)
at most 1 raw FileEntry (MetadataFile property) and
at most 1 MediaFileEntry (MediaFile property)
We shall refer to these last three entity types as the file entities.
Now there's more: As you can see, I am inheriting both ThumbnailFileEntry and MediaFileEntry from FileEntry, and let's not debate that! (for now), it's one of those end-of-story aspects of the design and both entity types will continue to grow later on.
This already brings me some significant issues right away in regards to the polymorphic associations induced by the relationships from the file entities to MediaFeedItem.
The first thing that you shall observe is that I have eliminated the navigation property from the derived file entities (ThumbnailFileEntry and MediaFileEntry) to the primary entity MediaFeedItem.
I do this because they already inherit that property defined in the base class FileEntry. As you can see, I do not delete the roles at the end of these associations.
The Relational Model
I shall be using the so-vastly-conceptually-superior TPT strategy for generating and mapping my Object Model to the RDB world (vs TPH/TPC).
I'm using EF5-rc, the EDMX model designer to design my model, and the EF5 DbContext Generator to generate a DbContext and POCOs cuz I wanna use the DbContext API.
As you can see, I can nicely generate the database model using the EF tools:
The Problem
When loading a new MediaFeedItem and saving it, I get the following error:
System.InvalidOperationException: Multicplicity constraint violated. The role 'MetadataFile' of the relationship 'MediaFeedModel.MediaFeedItem_MetadataFile' has multiplicity 1 or 0..1.
What am I doing wrong?
Looking at your problem one thing stands out, The FK relationship between File and MediaFeedItem is required (IE a file must have a MediaFeedItem), but in the case where you are in an extended version of File you probably dont want this.
What i think you want to do is one of the following:
change the multiplicity on MediaFeedItem_FileEntry to 0..1 - 0..1 so that it isnt required at either end
create a new extended type to handle your metadataFile type and remove the direct reference between the base type and MediaFeedItem
I personally think the second is a more elegant solution to your problem as its creating an actual type for your MetadataFile
What appears to be happening is that you are trying to create an extended type but the base type isnt actually a metadata file.
I'll try to explain my problem although to be honest I can't even understand it. After many changes in a couple of tables in my DB now I try to create a Foreign key and I'm getting this error when updating the EDMX.
gHOP.msl(410,10) : error 3007: Problem in Mapping Fragments starting at lines 410,
1511: Non-Primary-Key column(s) [UserGUID] are being mapped in both fragments to different conceptual side properties - data
inconsistency is possible because the corresponding conceptual side
properties can be independently modified.
gHOP.msl(1511,6) : error 3012: Problem in Mapping Fragments starting at lines 410, 1511: Data loss is possible in Itinerary.UserGUID.
An Entity with Key (PK) will not round-trip when:
(PK does NOT play Role 'Itinerary' in AssociationSet 'FK_Itinerary_Users' AND PK is in 'Itinerary' EntitySet)
gHOP.msl(410,10) : error 3012: Problem in Mapping Fragments starting at lines 410, 1511: Data loss is possible in Itinerary.UserGUID.
An Entity with Key (PK) will not round-trip when:
(PK is in 'Itinerary' EntitySet AND PK does NOT play Role 'Itinerary' in AssociationSet 'FK_Itinerary_Users' AND Entity.UserGUID
is not NULL)
Honestly, it's been a nightmare because I can't understand what's going on. Although I've given up and I won't create the FK if someone could at least give me a hint I would really appreciate it.
Thanks
Not sure how much access/control you have over the model but I've encountered similar issues before when updating entities in the db and then attempting to update the model. I usually just delete the entities from the model which you edited in the db! Rebuild without them. Then re-add them after the build. I find that Visual Studio is not always successful updating the model when structural/relational changes have been made in the db.
I am getting an error when I am updating the edmx file.
Error 3002: Problem in Mapping Fragment starting at line 3828:
Potential runtime violation of table Archive's keys (Archive.UserID):
Columns (Archive.UserID) are mapped to EntitySet Archive's properties
(Archive.UserID) on the conceptual side but they do not form the
EntitySet's key properties (Archive.ListID, Archive.UserID).
Any idea how to resolve this?
Check the mapping between the two tables. It sounds like the properties are mapped to the wrong field.
Take a look at: http://cticoder.wordpress.com/2008/10/14/entity-framework-error-3002-error-3003/
I get the following message:
{"Entities in 'Entities.ApprovalRequests' participate in the 'FK_ApprovalRequest_Audit' relationship. 0 related 'Audit' were found. 1 'Audit' is expected."}
I'm stumped, does anyone know what to make of it?
My EDMX had the FK and is correct, yet every time I get this message.
How one would go to debug this, would be most useful.
You probably tried to persist an entity of type ApprovalRequests with no associated entity of type Audit while your entity model specifies that each ApprovalRequests must have (at least) one Audit.