WebApi中使用EF一些报错及解决

 

System.InvalidOperationException:“No connection string named 'con' could be found in the application config file.”
翻译:
System.InvalidOperationException:“在应用程序配置文件中找不到名为‘con’的连接字符串。”

在WebApi项目中加上数据库连接字符串

 

System.Data.Entity.Core.MetadataException:“Unable to load the specified metadata resource.”
翻译
System.Data.Entity.Core.MetadataException:“无法加载指定的元数据资源。”

 

 

System.Data.Entity.Core.MetadataException:“Schema specified is not valid. Errors: 
Model1.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.”

翻译:
System.Data.Entity.Core.MetadataException:“指定的架构无效。错误:

Model1.ssdl(2,2):错误0152:未找到具有不变名称“System.Data.SqlClient”的ADO.NET提供程序的实体框架提供程序。确保提供程序已在应用程序配置文件的“entityFramework”部分注册。看见http://go.microsoft.com/fwlink/?LinkId=260882 了解更多信息。”

这个是因为我的WebApi项目没有引用EF(下面这两个dll)

EntityFramework.dll

EntityFramework.SqlServer.dll

上一篇:HTTP Method: GET,POST,HEAD,OPTIONS, PUT, DELETE, TRACE ,CONNECT


下一篇:kafka在线修改topic配置