且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“从数据库更新模型";

更新时间:2023-12-04 17:01:16

编辑

现在我知道您遇到了错误,请查看生成的代码(您甚至可以对类DPR_MM进行解决方案搜索以找到该类的所有实例).我猜想您的项目中已经有一个类Mvc4.Models.DPR_MM,该类已经具有DPR_TS作为成员,并且代码生成会看到该类并且不会生成另一个类,如下所示:

Now that I know you are getting an error, look at the generated code (you could even do a solution search for your class DPR_MM to find all instances of this class). I would guess you have a class Mvc4.Models.DPR_MM in your project that already has DPR_TS as a member and code generation sees that and won't generate another one, kind of like the following:

public partial class DPR_MM : EntityObject
{
    public global::System.Int32 DPR_TS
    {
    ...
    }
}

public partial class DPR_MM : EntityObject
{
    //maybe code generation fails because it doesn't want to do this a second time knowing it would be ambiguous 
    public global::System.Int32 DPR_TS  
    {
    ...
    }
}

除非存在一些数据库或名称空间问题,否则您应该始终能够生成新模型,因此请确保没有多余的文件,如@Mamu所说.或者您可以谷歌搜索它:
首次点击
另一个回答

You should always be able to generate a new model unless there is some database or namespace problem so make sure you don't have extra files laying around like @Mamu says. Or you could just google it:
first hit
another answer





初始答案

进行构建.然后,您应该根据从数据库更新模型"时选择的表查看所有新类(显然,从数据库更新模型"时必须选择新表)

Do a build. You should then see all your new classes based on the tables you selected when you "updated model from database" (obviously you have to select the new tables when "updating model from database")