I'm trying to create a new entity with an attribute of the type Log_ErrorId to link it to the Log_Error system entity.

This gives me the following error upon publishing: 

Upgrade Error
Could not create foreign key constraint. This may have happened because there are 'Attribute1' values of entity 'Entity1' with no corresponding value in entity 'Log_Error', or attribute 'Attribute1' of entity 'Entity1' is creating a circular dependency between entities. Check the Error Log for more information.

from the log:

Foreign key 'OSFRK_OSUSR_HMD_ENTITY1_OSLOG_ERROR_LOG_ERRORID' references object 'OUTSYSTEMS.DBO.OSLOG_ERROR' which is not a user table.
Could not create constraint or index. See previous errors.

While executing:
ALTER TABLE [OUTSYSTEMS].DBO.[OSUSR_HMD_ENTITY1] ADD CONSTRAINT [OSFRK_OSUSR_HMD_ENTITY1_OSLOG_ERROR_LOG_ERRORID] FOREIGN KEY ([LOG_ERRORID]) REFERENCES [OUTSYSTEMS].DBO.[OSLOG_ERROR] ([ID])


Entity is new and empty. No other entities refer to it. Any clue how to fix this?

I suspect it has something to do with the fact that Log_Error is a multitenant entity.

However I was able to link to the UserMT entity with no problems.

Solution

I think Log_Error is actually a view, iirc.

Solution

What is the difference between UserMT and Entity1?

Kilian Hekhuis wrote:

I think Log_Error is actually a view, iirc.

And a view can not be linked to?


That's what I would assume, given the error you showed: "Foreign key 'OSFRK_OSUSR_HMD_ENTITY1_OSLOG_ERROR_LOG_ERRORID' references object 'OUTSYSTEMS.DBO.OSLOG_ERROR' which is not a user table."

sunaif wrote:

What is the difference between UserMT and Entity1?

My apologies if I wasn't clear: I tried to link Entity1 to UserMT (which is also multitenant system entity) 

Kilian Hekhuis wrote:

That's what I would assume, given the error you showed: "Foreign key 'OSFRK_OSUSR_HMD_ENTITY1_OSLOG_ERROR_LOG_ERRORID' references object 'OUTSYSTEMS.DBO.OSLOG_ERROR' which is not a user table."

That makes sense.

I suppose I have to set up my datamodel in a different way. Thanks for the help!