【问题标题】:xception of type 'System.ArgumentException' occurred in System.Data.Entity.dllSystem.Data.Entity.dll 中出现“System.ArgumentException”类型的异常
【发布时间】:2015-06-25 18:27:03
【问题描述】:

我是 asp.net 和使用实体框架的新手。我们必须创建一个使用实体模型的网站。我们导出为 .dll 的实体模型(数据库)供 asp.net 网站使用。当我调用使用 dll 函数的函数时,我收到以下错误:

An exception of type 'System.ArgumentException' occurred in System.Data.Entity.dll but was not handled in user code

Additional information: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

该模型是使用实体框架版本 4.0.0.0 创建的。我可以添加到 asp.net 网站的最旧版本是 4.2.0.0 版。我不确定这是原因还是其他原因。一些帮助将不胜感激。

【问题讨论】:

    标签: c# asp.net entity-framework visual-studio-2013 entity-framework-4


    【解决方案1】:

    你的配置在哪里?类库没有配置,web项目需要有合适的实体框架配置。我认为这可能是你的问题。

    【讨论】:

    • 实体框架配置在两个程序(dll 和网站)中似乎都是正确的,有一个对 System.Data.Entity 的引用,并且这两个引用都是版本 4.0.0.0。作为旁注,用于创建模型的数据库是否应该在模型创建后存在?
    • 这可能是问题所在。我使用安装了 sql server 并因此连接到 localhost 的计算机创建了 dll。但是我目前使用的计算机使用 sqlexpress(.\SQLExpress 连接)。那我需要更改连接字符串吗?
    • 是的,到 .\SQLExpress。你需要发布你的数据库,如果你还没有这样做(如果你没有使用代码优先 EF)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多