I have the schema below : 
I tried to create a view and did everything to get IDStore_CardStore column NOT NULL in order to make it as the primary key in me EF entity but no success:
My aim is to select everything in the table StockCard even if it dosen’t exist in StockCardStores but i need to keep IDStore_CardStore not null and unique
SELECT ISNULL(dbo.StockCardsStores.IDStore_CardStore, NEWID()) AS IDStore_CardStore ,
NULLIF(dbo.StockCard.IDStockCardIndex, NEWID()) AS IDStockCardIndex ,
dbo.Stores.StoreName ,
dbo.StockCardsStores.IDPurchaseInvoice ,
NULLIF(dbo.StockCard.Designation,'')
FROM dbo.Stores
INNER JOIN dbo.StockCardsStores ON dbo.Stores.IDStore = dbo.StockCardsStores.IDStore
RIGHT OUTER JOIN dbo.StockCard ON dbo.StockCardsStores.IDStockCardIndex = dbo.StockCard.IDStockCardIndex
Is there any other workaround !
I think IDStore_CardStore already can’t be null, because it’s primary key in StockCardStores table. Maybe the problem is that IDStore_CardStore could have duplicated values in your view, making imposible to be the Primary Key of the view.
I don’t know your requirements, but uou can Fake a Primary key for your view making something like this in the query:
And then ID_PK can be the PK of he view in EF.