Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 3-Oct-13 0:52am
v2
Comments
Eduard Keilholz 3-Oct-13 6:52am    
What have you tried so far?
Atul Pachori 3-Oct-13 7:16am    
for this problem
adding a console application in same project solution
and add reference of mvc application in console application
and access model classes but problem is that
when i tried to access database record it gives me error
"the underlying provider failed to open"

i also copy connection string from web.config to app.config

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
 
Share this answer
 
v2
Comments
Atul Pachori 3-Oct-13 7:19am    
Dear Rk
please read my question again
i need to test model class method with out using any view and controller is this possible or not...

and one thing by using view and controller my application work properly...

but in my upcoming project i have to work only model part so how i do this...
♥…ЯҠ…♥ 3-Oct-13 7:24am    
Then copy the model,paste it in your upcoming projects model folder now you will be able to use it in your so called upcoming project right?
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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900