开发者

update model from database not working

I'm trying to generate my model from the database as usual, creating the model from the database using entity framework. I go through the wizard, add the connection string, test it, I select the tables I want开发者_运维问答 to import, everything as usual.

However the model is not created, I tried to update, re-create, everything that has come to my mind, with no success. Do you know what might be happening?

EDIT: Btw, in the Designer.cs nothing is created as well, so no model, but with a two table database.

I don't know if the problem might be that I have too many columns on a table? ha!


After wondering why the model was not being created from the database without showing any error, the problem was that my tables didn't have any primary key, and in conclusion the model cannot create entities without primary keys.

I'm not bothered by this, but I think an error or warning would have been more useful than an info entry.

Hope this will help another in the future.


Try this way: - In models section, add ADO.NET Entity Data Model. In the wizard select all tables. - At this point you should have an edmx file, open it, right click on the diagram and choose ADO.NET DbContext Geneartor. If you do not have this generator, download it from the Online Templates Section. - Now follow the wizard. - Now you should have the DBContext. Inside this you'll find all the item of the db and the DBEntities class necessary to work with the db.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜