Archives for Entity Framework
Multiple FROM statements in a LINQ expression
Multiple "from" statements are like nested foreach statements. MSDN example: var scoreQuery = from student in students from score in ; where score > 90 select new {…
FindAsync with non-primary key value
var foos = await (x => == userId).ToListAsync();
Quick way to print out generated sql
If you are working from an EF context, the context has its own LOG. This can be written out to your development console (see example below). = ;DataClassesDataContext context =…
Visualizing EDMX files (entity framework data model)
Ever wanted to reverse engineer a code-first Entity framework model ? Or simply generate a diagram from an existing model? Try the Entity Framework Power Tools. Power Tools
Converting a normal collection to IEnumerable
Suppose you are stuck with a namevaluecollection – it is not of type IQueryable or IEnumerable. So – none of your LINQ queries will work on it. Convert it to…
Update EDMX model with database changes
Open the EDMX file within Visual Studio – use an Open With command from the right click menu Open With -> Entity Data Model Designer Right click on the designer…
Linqer–Convert SQL statements to LINQ
LINQPad, the most popular LINQ tool out there , does not convert SQL statements into their equivalent LINQ syntax. However, a free tool called Linqer does just that. Linqer takes…
Inheriting an existing Entity Framework Implementation
Several quirks may pop up – the project may not work seamlessly in your local environment. Entity Framework generates a slew of files – most notably its mapping file (with…
Entity Framework–where to put the data folder
In your folder structure, where shoul you put the edmx data folder? As all EDMX files are representations (abstractions) of some relational database, they belong in the Models folder. The…