Entity Framework cant use the DbContext, model being created

霸气de小男生 提交于 2019-11-28 12:06:00

I see you are using the EDMX with Templates (.tt) for generating the classes. But if you are getting the information from a existing database, the wizard will create a ConnectionString compatible with ObjectContext (metadata informations and provider of entityframework).

The problem is that the connectionstring you are using is for ObjectContext (Database First and Model First). For the DbContext you should use the connectionstring without the metadata informations.

Your connection string should be:

<connectionStrings>
<add name="PasDBEntities" 
     connectionString="data source=localhost;
                       initial catalog=PasDB;
                       integrated security=True;
                       pooling=False;
                       multipleactiveresultsets=True;
                       App=EntityFramework"
     providerName="System.Data.SqlClient" />

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!