multiple edmx in the same .net solution

我怕爱的太早我们不能终老 提交于 2020-01-25 21:21:07

问题


I have 2 project in my .net solution.each one has entity data model.how I can make an association between two entities one in the first project data model while the other in the second project data model in the same solution?

what if each data model mapped to different database?


回答1:


As far as I know you can't achieve this within a reasonable solution.




回答2:


It is impossible to have a database relation between two fields in separate databases, however, you can do this of course with server side logic in your application code. If you do, make sure you add a trigger to enforce referential integrity to make sure the relation can be made if it requires a field not to be null

Add Foreign Key relationship between two Databases

Create Trigger dbo.MyTableTrigger ON dbo.MyTable, After Insert, Update
As
Begin

   If NOT Exists(select PK from OtherDB.dbo.TableName where PK in (Select FK from inserted) BEGIN
      -- Handle the Referential Error Here
   END

END


来源:https://stackoverflow.com/questions/3185653/multiple-edmx-in-the-same-net-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!