实体框架上下文和删除的连接字符串问题
我有一个简单的查找删除案例:
var query = CompanyUsers
.Where ( cu => cu.eMail.Contains( "[email protected]") || cu.eMail.Contains( "[email protected]"))
ServicesEntities se = new ServicesEntities();
se.DeleteObject( query );
ServiceEntities 是一个 EntityFramework 4.1 DLL。 DLL 中唯一的就是 EF 模型。
当我尝试删除时,我得到:
“ArgumentException:在配置中找不到指定的命名连接,不适合与 EntityClient 提供程序一起使用,或者无效。”
如果我尝试在 app.config 文件中添加连接字符串的名称,如下所示:
ServicesEntities se = new ServicesEntities("ServicesEntities");
我得到: ArgumentException: 初始化字符串的格式不符合从索引 0 开始的规范。
如何使用我的 EF 模型并使用执行删除上下文。是否可以传递 LINQPad 在属性选项卡中创建的连接字符串,或者至少使用 app.config 中的连接字符串?
I have a simple find delete case:
var query = CompanyUsers
.Where ( cu => cu.eMail.Contains( "[email protected]") || cu.eMail.Contains( "[email protected]"))
ServicesEntities se = new ServicesEntities();
se.DeleteObject( query );
ServiceEntities is a EntityFramework 4.1 DLL. The only thing in the DLL is the EF model.
When I try to delete I get:
"ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
If I try adding the name of the connection string in the app.config file like this:
ServicesEntities se = new ServicesEntities("ServicesEntities");
I get: ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
How can I use my EF model and perform deletes using the conext. Is it possible to pass through the connection string that LINQPad appears to be creating in the properties tab or at the minimum use the one from the app.config?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论