Tôi đang sử dụng ASP.NET 5 và Entity Framework 6 (chính xác 6.1.3), sau link này. Thử mọi giải pháp khác nhau nhưKhông thể tải tệp hoặc lắp ráp 'EntityFramework.SqlServer, Phiên bản = 6.0.0.0, Văn hóa = trung lập, PublicKeyToken = b77a5c561934e089'
- scrapping Version trong appconfig
- Thêm
<dependentAssembly>
- Cài đặt lại EntityFramework 6 một lần nữa sử dụng
Update-Package -reinstall EntityFramework
- Kiểm tra EntityFramwork.SqlServer
- dọn dẹp% temp% và đã làm sạch sẽ xây dựng cùng với xây dựng lại độc lập
Tôi nhận được lỗi ở đây
[DbConfigurationType(typeof(CodeConfig))]
public class MyContext : DbContext
{
public MyContext()
: base("DefaultConnection") <-- error here
{
}
}
Nhưng vẫn không thể giải quyết lỗi này, bất kỳ liên kết hữu ích sẽ được đánh giá
Không thể tải tập tin hoặc lắp ráp 'EntityFramework.SqlServer, Version = 6.0.0.0 , Văn hóa = trung lập, PublicKeyToken = b77a5c561934e089 'hoặc một trong các phụ thuộc của nó. Hệ thống không thể tìm thấy một file nào đó. ":" EntityFramework.SqlServer, Version = 6.0.0.0, Culture = trung tính, PublicKeyToken = b77a5c561934e089"
Stack Trace
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Data.Entity.Utilities.TypeExtensions.CreateInstance[T](Type type, Func`2 exceptionFactory)
at System.Data.Entity.Utilities.TypeExtensions.CreateInstance[T](Type type, Func`3 typeMessageFactory, Func`2 exceptionFactory)
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.<.ctor>b__1()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.GetConfiguration()
at System.Data.Entity.Infrastructure.DependencyResolution.InternalConfiguration.get_Instance()
at System.Data.Entity.DbConfiguration.get_DependencyResolver()
at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model)
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
at myproject.data.myprojectContext..ctor() in D:\Projects\Personal\myproject\myproject.data\myprojectContext.cs:line 12
at myproject.data.Infrastructure.DatabaseFactory.Get() in D:\Projects\Personal\myproject\myproject.data\Infrastructure\DatabaseFactory.cs:line 9
at myproject.data.Repository`1.get_DataContext() in D:\Projects\Personal\myproject\myproject.data\Repository.cs:line 28
at myproject.data.Repository`1..ctor(IDatabaseFactory databaseFactory) in D:\Projects\Personal\myproject\myproject.data\Repository.cs:line 21
at myproject.data.Repository.ProfileRepository..ctor(IDatabaseFactory databaseFactory) in D:\Projects\Personal\myproject\myproject.data\Repository\ProfileRepository.cs:line 9
Web.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="...." />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Bạn có thể thử làm sạch các file tạm thời thường dưới 'C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Tệp ASP.NET tạm thời và giải pháp sạch? – Win
Ngoài ra, hãy thử 'giải pháp nhấp chuột phải → giải pháp sạch → và xây dựng lại ' Và cũng có điều tôi đã gặp phải trước đó là nhiều mục của mã thông báo khóa công khai đã được thêm vào' app.config' của tôi khi tôi gặp lỗi này. Strange không phải là nó – Eon
Trường hợp xấu nhất bạn có thể loại bỏ nó hoàn toàn, và cài đặt lại thay vì cài đặt lại? – Win