Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework and SQL Server Synonyms

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?

like image 219
ProfK Avatar asked Dec 06 '10 18:12

ProfK


People also ask

What is Entity Framework SQL Server?

Entity Framework Core is a modern object-database mapper for . NET. It supports LINQ queries, change tracking, updates, and schema migrations. EF Core works with many databases, including SQL Database (on-premises and Azure), SQLite, MySQL, PostgreSQL, and Azure Cosmos DB.

What is SQL Server synonym?

A synonym is a database object that serves the following purposes: Provides an alternative name for another database object, referred to as the base object, that can exist on a local or remote server.

Is Entity Framework only for SQL Server?

For example, the Entity Framework Core library supports over ten popular database engines, including Microsoft SQL Server, Oracle, PostgreSQL, MySQL, and SQLite. Sometimes, you may want to use more than one of the stated database providers. This post will look at configuring your .

What is meant by Entity Framework?

The Entity Framework enables developers to work with data in the form of domain-specific objects and properties, such as customers and customer addresses, without having to concern themselves with the underlying database tables and columns where this data is stored.


2 Answers

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.

like image 164
Shiraz Bhaiji Avatar answered Oct 14 '22 18:10

Shiraz Bhaiji


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 :-)

like image 35
camainc Avatar answered Oct 14 '22 18:10

camainc