|
Проблема при использовании DBContext-а
|
|||
---|---|---|---|
#18+
Привет. Возникает проблема при использовании EF в ASP.NET MVC-приложении. Ну прежде всего сообщение об ошибке: The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development.... Код, который выбрасывает исключение, следующий using (ModelHCMContainer db = new ModelHCMContainer()) { var v = db.HCMUsers.ToList(); } Строка соединения такая: <add name="HCMConnection" connectionString="Data Source=DEV-PROG-01; Initial Catalog=HCM; user id=USER; password=PASSWORD; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> Ну и класс ModelHCMContainer обьявлен как public partial class ModelHCMContainer : DbContext { public ModelHCMContainer() : base("name=HCMConnection") { } ... Никаких .ssdl, csdl у меня не используется (во всяком случае, я не вижу этих файлов в составе проекта), проект создавался как code-first. В чем может быть проблема? Спасибо. ... |
|||
:
Нравится:
Не нравится:
|
|||
10.06.2016, 23:44 |
|
Проблема при использовании DBContext-а
|
|||
---|---|---|---|
#18+
Да, полное сообщение об ошибке такое: The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. If you are creating your own DbConnection, then make sure that it is an EntityConnection and not some other type of DbConnection, and that you pass it to one of the base DbContext constructors that take a DbConnection. To learn more about Code First, Database First, and Model First see the Entity Framework documentation here: http://go.microsoft.com/fwlink/?LinkId=394715 >To fix this problem do not remove the line of code that throws this exception Не, ну нормально? Да эта строка кода и не удалялась и тем не менее эксепшон возник. Небольшие проблемы с логикой у этих писателей. ... |
|||
:
Нравится:
Не нравится:
|
|||
11.06.2016, 00:07 |
|
Проблема при использовании DBContext-а
|
|||
---|---|---|---|
#18+
mabanza, авторmake sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. А также: авторTo learn more about Code First, Database First, and Model First see the Entity Framework documentation here: http://go.microsoft.com/fwlink/?LinkId=394715 ... |
|||
:
Нравится:
Не нравится:
|
|||
13.06.2016, 21:30 |
|
|
start [/forum/topic.php?fid=17&msg=39254531&tid=1349390]: |
0ms |
get settings: |
11ms |
get forum list: |
15ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
183ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
47ms |
get tp. blocked users: |
1ms |
others: | 247ms |
total: | 527ms |
0 / 0 |