zoukankan      html  css  js  c++  java
  • 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:“无法加载指定的元数据资源。”

     这个是App.Config或者Web.config中的连接字符串有问题,

    <add name="AuthorizeContainer" connectionString="metadata=res://*/Models.Authorize.csdl|res://*/Models.Authorize.ssdl|res://*/Models.Authorize.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=Server;Initial Catalog=EIPS;Persist Security Info=True;User ID=sa;Password=123;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

    “metadata=res://*/Models.Authorize.csdl|res://*/Models.Authorize.ssdl|res://*/Models.Authorize.msl;”

    我的这部分是从其他地方拷过来的,这个和edmx中的不一样就产生这个报错

    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

  • 相关阅读:
    MySQL的char和varchar针对空格的处理
    单KEY业务,数据库水平切分架构实践
    接口测试学习笔记1-接口测试的用例设计
    Robot Framework源码解析(2)
    Robot Framework 源码解析(1)
    Python学习笔记1 -- TypeError: 'str' object is not callable
    OKHttp源码学习同步请求和异步请求(二)
    OKHttp源码学习--HttpURLConnection HttpClient OKHttp Get and post Demo用法对比
    Javapoet源码解析
    Universal-Image-Loader源码解解析---display过程 + 获取bitmap过程
  • 原文地址:https://www.cnblogs.com/heyiping/p/15134338.html
Copyright © 2011-2022 走看看