我正在尝试将实体框架与SQL Server一起使用。有很多例子说我需要添加EntityFramework.SqlServer
包以使其正常工作。但据我了解they renamed the package to EntityFramework.MicrosoftSqlServer。在我的情况下,我找不到任何这些包。我找到的唯一包含EntityFramework
和SqlServer
名称的包是EntityFramework.SqlServerCompact
,但后来我遇到异常:
System.IO.FileLoadException未被用户代码
处理 FileName = EntityFramework.SqlServer,Version = 6.0.0.0,Culture = neutral, PublicKeyToken = b77a5c561934e089 FusionLog =“”HResult = -2146234300
Message =无法加载文件或程序集'EntityFramework.SqlServer, Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'或 其中一个依赖项。需要一个强名称的程序集。 (来自HRESULT的异常:0x80131044)Source = mscorlib StackTrace: at System.RuntimeTypeHandle.GetTypeByName(String name,Boolean throwOnError,Boolean ignoreCase,Boolean reflectionOnly, StackCrawlMarkHandle stackMark,IntPtr pPrivHostBinder,Boolean loadTypeFromPartialName,ObjectHandleOnStack类型) at System.RuntimeTypeHandle.GetTypeByName(String name,Boolean throwOnError,Boolean ignoreCase,Boolean reflectionOnly, StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean loadTypeFromPartialName) at System.RuntimeType.GetType(String typeName,Boolean throwOnError,Boolean ignoreCase,Boolean reflectionOnly, StackCrawlMark&安培; stackMark) at System.Type.GetType(String typeName,Boolean throwOnError) at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.TryGetInstance(String providerTypeName) 在System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.RegisterSqlServerProvider() 在System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.RegisterDbProviderServices() at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type,String name) 在System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver。<> c__DisplayClass1.b__0(元组2 t) at System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey) key,Func2 valueFactory) at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key) at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext() 在System.Linq.Enumerable.FirstOrDefault [TSource](IEnumerable1 source, Func
2谓词) at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type 类型,对象键) at System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type 类型,对象键) at System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService [T](IDbDependencyResolver 解析器) 在System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection) internalConnection,DbCompiledModel模型) at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)... InnerException: 的HResult = -2146234300 消息=需要具有强名称的程序集。 (HRESULT异常:0x80131044) 的InnerException:
project.json
{
"webroot": "wwwroot",
"userSecretsId": "aspnet5-Iwatch.Accounting.Web.Angular-03e60bec-48ff-4682-8638-aa06e0f97867",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.Commands": "7.0.0-beta5",
"EntityFramework.SqlServerCompact": "6.1.3",
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
"Microsoft.Framework.Logging": "1.0.0-beta5",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
"Newtonsoft.Json": "8.0.3",
"Microsoft.AspNet.Identity": "3.0.0-beta5",
"EntityFramework.Relational": "7.0.0-beta5",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5",
"Microsoft.AspNet.SignalR.SqlServer": "3.0.0-beta5"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Iwatch.Accounting.Data.Repository": "1.0.0-*",
"Iwatch.Accounting.Data.Logic": "1.0.0-*"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}