首先从数据库,实体框架4数据库更新edmx [英] Update edmx from database, entity framework 4 database first

查看:81
本文介绍了首先从数据库,实体框架4数据库更新edmx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Visual Studio 2010和Entity Framework 4中有解决方案。问题已经过时但仍然没有我找到的答案对我来说真的很有用。

解决方案具有扩展数据库和现有edmx中的模型的元数据类,其中包含3个标准文件,用于EF 4(csdl,msl,ssdl)。

当我执行从数据库更新模型选项时,类,db集合创建得很好,但在运行时它会中断并抛出一个错误,我在数据库中修改或创建的实体不是当前上下文的一部分。

问题是元数据文件没有刷新所以他们有反映数据库更改的正确映射。

运行自定义工具,转换T4模板并使用代码生成选项生成类失败对我来说。

所以请有人能告诉我确切的简单地添加或修改数据库,刷新更改和使用修改所需的步骤,而无需在XML中手动编写映射:)



比ks



我尝试过:



- 从数据库刷新模型

- 为db上下文生成代码

- 为模板运行自定义工具

- 转换T4选项

Hi,
I have solution in Visual Studio 2010 and Entity Framework 4. Problem is old but still none of the answers I have found really worked for me.
Solution have metadata classes that extends models in database and existing edmx with 3 standard files for EF 4 (csdl,msl,ssdl).
When I do the "Update Model from database" option, classes, db sets are created just fine but in runtime it breaks and throws an error that entity I was modify or create in database is not part of the current context.
Problem is that metadata files are not refreshed so they have proper mappings that reflects the database changes.
Running custom tool, transform T4 templates and generating classes using Code Generation option failed for me.
So please can someone show me the exact steps that are needed to simply add or modify database, refresh changes and use modifications without having to write manually mappings in XML :)

Thanks

What I have tried:

- Refreshing model from database
- Generating code for db context
- Running custom tools for templates
- Transforming T4 options

推荐答案

升级实体框架,我记得那个版本,从这个意义上来说,这是一个痛苦的世界,只需通过视觉工作室中的nuget升级。



或者通常有效的修复,删除有关edmx的所有文件,然后添加一个新文件。我知道特别乏味,因为该版本不是很擅长添加自定义程序,除非您通过右键单击设计界面来实现,但仍然如此。最安全的赌注,但升级它的人,新的更好,并且更快的事情
Upgrade entity framework, i remember that version, it is a world of pain in that sense, just upgrade through nuget in visual studio.

Or the fix that usually worked, delete all files about the edmx and then make add a new one. Especially tedious i know, as that version isn't very good at adding custom procedures unless you do it through rightclicking on design interface, but still. Safest bet, but upgrade it man, the newer ones work a lot better, and faster for that matter


这篇关于首先从数据库,实体框架4数据库更新edmx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆