Problems and solutions in building EF6.0+MVC4 frame

Source: Internet
Author: User

Issue one: " failed to load file or assembly" EntityFramework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"

Cause:

With the NuGet management package, there are different versions of the Entity Framework in the same solution, and it is possible to install different versions of the Entity Framework at different times, so this problem occurs.

Solution:

1. NuGet Package for Management solution, tool-and library packages manager

2. If there are two entityframework installed, then uninstall one (i uninstalled the lower version)

3. Otherwise, locate EntityFramework in the installed package, select it, then click the "Update" button

4. Select the items you want to update (typically automatically default to the items that need to be updated), click the "OK" button

5. Wait for the update to complete and resolve.

Issue two: In the Run Program Times error: " if used in code first mode, the code generated for Database first and model first development using the T4 template may not function correctly." To continue using Database first or Model first, make sure that you specify the Entity Framework connection string in the config file that executes the application. To use the classes generated from Database first or Model first for code first, add any additional configuration using the attributes or Dbmodelbuilder API, and then remove the code that throws the exception. "Normal at compile time.

Solution:

Modify the method "Onmodelcreating" under the context class to:

1 protected Override void onmodelcreating (Dbmodelbuilder modelBuilder) 2 {3 modelbuilder.conventions.remove<pluralizingtablenameconvention>(); 4 Base . Onmodelcreating (ModelBuilder); 5 6 // throw new Unintentionalcodefirstexception (); 7 }      

Problems and solutions in building EF6.0+MVC4 frame

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.