荆门龙泉中学,鼎盛王朝军事论坛,str6708
最近在做一个新项目开发时,碰到了下面这个问题.在使用ef时,提示错误信息
to continue using database first or model first ensure that the entity framework connection string is specified in the config file of executing application. to use these classes, that were generated from database first or model first, with code first add any additional configuration using attributes or the dbmodelbuilder api and then remove the code that throws this exception.
在网上也找了一些回复,但是基本都没有说明怎么解决的,我在这里说一下,
这个原因是因为web.config中配置的连接字符串决定的.不同的连接字符串是不一样的
下面这种字符串是code first的,
<add name="xxxx" providername="system.data.sqlclient" connectionstring="data source=xx.xx.x8.xx;initial catalog=xx;persist security info=true;user id=xx;password=xx;"/>
通过ef同步数据库的类,应该使用下面这种链接字符串
<add name="xx" connectionstring="metadata=res://*/xx.csdl|res://*/xx.ssdl|res://*/xx.msl;provider=system.data.sqlclient;provider connection string="data source=xx.xx.xx.xx;initial catalog=xx;persist security info=true;user id=sa;password=xx;multipleactiveresultsets=true;app=entityframework"" providername="system.data.entityclient" />
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论