1
votes

I have a view using group by statement on it. Because of that, view does not have a primary key column.

In EF, your tables and views need to have a primary key or id column. As I search To force entity framework to use a column as a primary key, use ISNULL. This is a solution for sql but I am using Oracle database.

So that I try to use ISNULL() equivalent NVL() in Oracle but it did not solve the problem.

The error log in the edmx file is below: The table/view 'TRANSFERS' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity, you will need to review your schema, add the correct keys, and uncomment it

Thanks

1
Here you find something on How to Ask and how to build a minimal reproducible example that can be useful to clarify your questionAleksej

1 Answers

0
votes

I'm not familiar with Entity Framework, but if the question is how to add a primary key on a view, it can be done by creating the primary key as disable. Look at the following example, view v_test is defined as a group by query from underlying table.

create table t_test (a number);
create or replace view v_test 
(col1, col2, constraint pk_test primary key (col1) rely disable novalidate) as
select a col1, count(1) col2
from t_test group by a;