如何在不使用视图和控制器的情况下检查模型类功能是否正常工作 [英] how i can check model classes function work properly or not without using view and controller

查看:77
本文介绍了如何在不使用视图和控制器的情况下检查模型类功能是否正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是mvc的初学者。我只有数据库和模型部分的mvc应用程序和数据库是使用实体数据模型edmx文件连接。现在我想检查模型类方法是否正常工作,即正确插入或检索数据是否可行?

I am beginner in mvc. I have only database and model part of mvc application and database is connect using entity data model edmx file. Now i want to check that model classes method work properly or not i.e insert or retrieve data correctly or not is this possible or not?

推荐答案

Hi Atul,


在MVC中有一个名为scaffolding的概念,它有助于使用带有CRUD操作的动作模型类自动创建视图和控制器。

你可以试试为你的模型类创建一个视图并尝试测试数据库。

我希望这个 link [ ^ ]会对你有所帮助。



问候,

RK
Hi Atul,

In MVC there is a concept called scaffolding, which helps to automatically create a view and controller using action model class with CRUD operations.
You can try creating a view for your model class and try testing the database.
I hope this link[^] would help you a bit.

Regards,
RK


您应该使用任何单元测试框架,或者只将Test项目添加到Unit test yur模型中。请参阅此链接,其中显示了如何为模型创建测试类(尽管可以使用大量的单元测试参考)。



http://nerddinnerbook.s3.amazonaws.com/ Part12.htm [ ^ ]



如果它有效,那么当你在实际项目开始后开始生成数据库(CodeFirst方法)时应该没有问题。



希望这有助于
You should be using any of the Unit test frameworks or just add a Test project to Unit test yur model only . Refer this link which shows how to create test classes for your models( There are lots of Unittesting references available though ).

http://nerddinnerbook.s3.amazonaws.com/Part12.htm[^]

If it works then there should not be a problem when you start to have a DB generated( CodeFirst approach) from this later when the actual project begins.

Hope this helps


这篇关于如何在不使用视图和控制器的情况下检查模型类功能是否正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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