简体   繁体   English

实体框架和SQL Server同义词

[英]Entity Framework and SQL Server Synonyms

Hasty research tells me that even EF4 still doesn't support SQL Server synonyms. 仓促的研究告诉我,即使EF4仍然不支持SQL Server同义词。 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? 使用POCO或代码优先方法是否没有更优雅的解决方法?

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. 为模型中的视图提供同义词的名称。

See this post - apparently you can do it with some manual manipulation of the edmx. 看到这篇文章 - 显然你可以通过对edmx的一些手动操作来实现。

Making an Entity Framework Model span multiple databases 使实体框架模型跨越多个数据库

It's not elegant, though, so it doesn't answer your question :-) 但它并不优雅,所以它没有回答你的问题:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM