The type of one of the expressions in the join clause is incorrect in Entity Framework

The types and the names of the properties in the anonymous types must match: new { p1 = q.QOT_SEC_ID, p2 = dpr.DPR_TS } equals new { p1 = (decimal)p.PAY_SEC_ID, p2 = p.PAY_DATE } or if p.PAY_SEC_ID were an int?: new { p1 = (int?)q.QOT_SEC_ID, p2 = dpr.DPR_TS } equals new { p1 = p.PAY_SEC_ID, p2 … Read more

EF Including Other Entities (Generic Repository pattern)

Use just the Include extension on IQueryable. It is available in EF 4.1 assembly. If you don’t want to reference that assembly in your upper layers create wrapper extension method in your data access assembly. Here you have example: public static IQueryable<T> IncludeMultiple<T>(this IQueryable<T> query, params Expression<Func<T, object>>[] includes) where T : class { if … Read more

ASP.NET add migration ‘composite primary key error’ how to use fluent API

On EF core .. Composite keys can only be configured using the Fluent API – conventions will never setup a composite key and you can not use Data Annotations to configure one. Here is the Fluent API version : Note: This is just an example. Please adjust it according to your use case. // (In … Read more

Why is inserting entities in EF 4.1 so slow compared to ObjectContext?

As already indicated by Ladislav in the comment, you need to disable automatic change detection to improve performance: context.Configuration.AutoDetectChangesEnabled = false; This change detection is enabled by default in the DbContext API. The reason why DbContext behaves so different from the ObjectContext API is that many more functions of the DbContext API will call DetectChanges … Read more

Self referencing loop detected – Getting back data from WebApi to the browser

Is this because the Question has Answers and the Answers have a reference back to Question? Yes. It cannot be serialized. EDIT: See Tallmaris’s answer and OttO’s comment as it is simpler and can be set globally. GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Re‌​ferenceLoopHandling = ReferenceLoopHandling.Ignore; Old Answer: Project the EF object Question to your own intermediate or DataTransferObject. This Dto … Read more

No executable found matching command “dotnet-ef”

Entity Framework Core 1.0 You should just need to update the tools section of your project.json file to include this: “Microsoft.EntityFrameworkCore.Tools”: { “version”: “1.0.0-preview1-final”, “imports”: [ “portable-net45+win8+dnxcore50”, “portable-net45+win8” ] } This should make the dotnet ef commands available. Important I should also note here that the dotnet ef commands will only be available when running … Read more