Entity Framework and SQL Server Synonyms

夙愿已清 提交于 2019-12-10 03:11:16

问题


Hasty research tells me that even EF4 still doesn't support SQL Server synonyms. What are my options for setting up a synonym based entity set as if it were a table based entity set? The crudest I have come up with is to copy the underlying table for the synonym, add it to my model, and then rename the entity set in the store model. Is there no more elegant workaround using the POCO or code-first approach?


回答1:


See this post - apparently you can do it with some manual manipulation of the edmx.

Making an Entity Framework Model span multiple databases

It's not elegant, though, so it doesn't answer your question :-)




回答2:


You could create a view that selects data from your synonym and then add the view to your model. Giving the view in your model the name of the synonym.



来源:https://stackoverflow.com/questions/4369748/entity-framework-and-sql-server-synonyms

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