I am using ASP.NET 5 and Entity Framework 6 (precisely 6.1.3), following this link. Tried every different solution like
- Scrapping of Version in appconfig
- Adding
<dependentAssembly> - Reinstalling EntityFramework 6 again using
Update-Package -reinstall EntityFramework - Check EntityFramwork.SqlServer
- Cleared %temp% and did clean build along with standalone rebuild
I get error here
[DbConfigurationType(typeof(CodeConfig))]
public class MyContext : DbContext
{
public MyContext()
: base("DefaultConnection") <-- error here
{
}
}
But still couldn't resolve this error, any helpful links would be appreciated
Could not load file or assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.":"EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, 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>
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Filesand Clean Solution? - Winright click solution → clean solution → and rebuildAnd also something I have encountered before was that multiple entries of the public key token had been added to myapp.configwhen I had this error. Strange isn't it - Eon