Entity Framework Code First Error: The model backing the … context has changed …

The other day I received an error “System.InvalidOperationException was unhandled”

“The model backing the ‘XXXXContext’ context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).”

It turns out that I upgraded Entity Framework packages in only some of the projects within the solution and missed one project.

After I upgraded to the Entity Framework package to the latest one for that project, the error is fixed.

Lesson Learned: if you are going to upgrade one project’s Entity Framework NuGet Packages, be sure to verify all the NuGet packages in ALL of your solution projects have the latest Entity Framework package as well.

Advertisements

How to do “In” a list of values with LINQ

I have always done it the following way.

List<string> listMessageUid = new List<string>() { "100013", "100014", "100015", ... };

using (var uow = new MyUOW())
{
List<XXXXEmail> emails = uow.XXXXEmailRepository.Find(x=> listMessageUid.Contains(x.MessageUid)).ToList();
// do something with
}

But I am curious how efficient the LINQ generated SQL query is.

SELECT 
[Extent1].[Id] AS [Id],
[Extent1].[MessageUid] AS [MessageUid],
[Extent1].[xxxx] AS [xxxx]
FROM [dbo].[CourtEmail] AS [Extent1]
WHERE ([Extent1].[MessageUid] IN ('100013', '100014', '100015', '100016', '100018', '100020', '100025', '100029', '100030', '100069', '100070', '100071', '100072', '100073', '100074', '100076', '100079', '100088', '100089', '100090', '100091', '100092', '100389', '100390', '100392')) AND ([Extent1].[MessageUid] IS NOT NULL)

Conclusion:

I like how LINQ’s Contains behaves like TSQL’s IN.

10 Reason Why Content Goes Viral

 

  1. Inspire awe, laughter, or amusement.
  2. Appeal to people’s narcissistic side (think BuzzFeed quizzes)
  3. Long-form content has less competition, and more shares on average.
  4. List posts and infographics are more likely to be shared.
  5. Make sure your article inspires trust. Have a byline, and bio. Make sure you have a professional logo and design as well.
  6. Mix text with visually appealing elements.
  7. Implement social metadata such as the Facebook preview image
  8. Reach out to influencers before you write your content.
  9. Promote your articles after it’s been published for a week
  10. Tuesday is the best day to publish and promote content

Reference:

http://www.huffingtonpost.com/noah-kagan/why-content-goes-viral-wh_b_5492767.html

Entity Framework 6 SQL Server Compact 4.0 Slow Startup

Problem

The development machine is 64-bit.  It takes ~20 seconds to open the SQL Server Compact database.

None of the online tips I’ve found fix it.

Partial Solution

The best I can do is to change the project property Build

I check Prefer 32-bit.

image

Now it takes 9 seconds to open, still too slow.

Reference:

http://erikej.blogspot.com/2013/08/faq-why-is-opening-my-sql-server.html

http://stackoverflow.com/questions/18113829/sql-server-compact-4-startup-loadnativebinaries-slow