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

  • 相关阅读:
    浅谈线性 Linear
    Github TinyRenderer渲染器课程实践记录
    蓝点无限UWB TDOA 低功耗标签 功耗测试
    UWB DW1000 BP30 测距代码架构
    C语言
    C语言
    张量tensor 和张量分解 tensor decomposition
    Manifold learning流行学习和谱聚类
    机器学习里面的核kernel, 维数灾难
    机器学习评价方法
  • 原文地址:https://www.cnblogs.com/heyiping/p/15134338.html
Copyright © 2011-2022 走看看