Entity-framework table without unique key

There is a table in the database that I cannot modify, I am trying to use it with Entity Framework. There is no unique key for the reasoning, not even all columns, all columns are of type nvarchar (x) and I cannot change the database to include a column of type rownumber.

Is there a way to get this table in Entity Framework so that I can run queries on it? If I need to update it, I will write my own storeproc file.

+2


source to share


2 answers


You can create DefiningQuery in the model using Primary Key-column.

For example, it will search for SQL Server like this:
"select newid () as pk, a.City, a.AddressLine1, a.AddressLine2 from AdventureWorks.Person.Address a" But this object will be read-only.



+1


source


Is it possible to display a VIEW that returns table data + artificial key? Or a stored process that does the same thing?



0


source







All Articles