【发布时间】:2010-10-18 19:50:21
【问题描述】:
我正在制作一个小库 (DLL) 来管理用户及其角色/权限。计划是能够将此 dll 添加到 MVC 项目并能够操纵用户/角色/等。所有数据都驻留在 SQL 数据库中。
我正在使用实体框架进行数据访问。
所以当我初始化一个新的 RoleManager(这是我正在制作的 lib 中的主类的名称)时,我会为它提供一个如下所示的 connectionString:
RoleManager roleManager = new RoleManager(string connectionString);
然后在构造函数中我这样做:
db = new RoleManagerEntities(connectionString); //This is the EntityFramework
我正在尝试提供此连接字符串(以及许多其他字符串)
"metadata=res://*/RoleManager.csdl|res://*/RoleManager.ssdl|res://*/RoleManager.msl;provider=System.Data.SqlClient;provider connection string='Data Source=localhost;Initial Catalog=Login;Integrated Security=True;Connection Timeout=60; multipleactiveresultsets=true'"
我收到以下错误:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
这个问题是由于尝试从我的新项目中实例化 EF 而不提供连接字符串并且我的应用程序配置中没有任何默认设置的结果。太糟糕了,我现在不能删除它。
【问题讨论】:
标签: c# sql entity-framework