我正在制作一个小库(DLL)来管理用户及其角色/权限。计划是能够将此 dll 添加到 MVC 项目中并能够操作用户/角色等。所有数据都驻留在 SQL 数据库中。
我正在使用实体框架进行数据访问。
因此,当我初始化一个新的 RoleManager(这是我正在制作的库中主类的名称)时,我向它提供一个连接字符串,如下所示:
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 而没有提供连接字符串,并且我的应用程序配置中没有任何默认值。可惜现在还不能删除。
只需将连接字符串信息从 DLL 配置文件复制到可执行配置文件即可。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)