Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More EF Perplexities (a sequel)
Message
General information
Forum:
ASP.NET
Category:
Entity Framework
Environment versions
Environment:
C# 5.0
OS:
Windows Server 2016
Network:
Windows Server 2016
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01646596
Message ID:
01646599
Views:
32
>I generated EF Entities from a Database. Now I would like run a raw sql against that same database that is not included in the generated entities.
>I thought I'd use the DbContext .Database.SqlQuery method, but that throws an exception (unitntionalCodeFirsteExcption.
>
>"The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. "
>
>So does that mean one cannot access the database in this way., or is there a approach hidden somewhere that I am still to discover?

Assuming the tables you want to run the Sql against are in the EF Model:

https://msdn.microsoft.com/en-us/library/jj592907(v=vs.113).aspx

UPDATE: Ah, I see that that's what you were doing - so, no - the table needs to be in the model (for obvious reasons).....
Previous
Reply
Map
View

Click here to load this message in the networking platform