Joining tables using more than one column in Linq To Entities

You can write it using two from expressions like below: from a in Table1s from b in Table2s where a.ID1Table1 == b.ID1Table2 && a.ID2Table1 == b.ID2Table2 select new {a.ID1Table1, a.ID2Table1, a.Value1Table1, b.ID3Table2, b.Value1Table2} Using join: from a in Table1s join b in Table2s on new{PropertyName1 = a.ID1Table1, PropertyName2 = a.ID2Table1} equals new{PropertyName1 = b.ID1Table2, PropertyName2 … Read more

Using DateTime properties in Code-First Entity Framework and SQL Server

You can specify the type in Fluent API: modelBuilder.Entity<Book>() .Property(f => f.DateTimeAdded) .HasColumnType(“datetime2”); This creates a datetime2(7) column in the database. If you want to finetune the precision you can use: modelBuilder.Entity<Book>() .Property(f => f.DateTimeAdded) .HasColumnType(“datetime2”) .HasPrecision(0); … for a datetime2(0) column in the DB. However, the code you have shown in your question works … Read more

Use the ColumnAttribute or the HasKey method to specify an order for composite primary keys

It took a lot of fiddling about and testing different things. I was clueless until I decided to make a new vanilla project with the similar data structure from scratch. And when I installed EntityFramework from NuGet, I was shown a message: Known Issues with Entity Framework 4.x and .NET Framework 4.5 Entity Framework 4.1 … Read more

Can’t get EntityFunctions.TruncateTime() to work

I faced this problem recently when I upgraded my Web Application from Entity Framework 5 to Entity Framework 6. Then, I realized that System.Data.Entity DLL needs to be removed from the application completely in order to work with Entity Framework 6. Entity Framework 6 is not part of .NET Framework anymore and therefore it is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)