Click here to Skip to main content
13,086,662 members (61,380 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i m beginer in mvc 3

i have set up database for application on server.
all is working well...except

when i m creating a new record this gets error.

@model Surveys.SurveysServiceReference.Survey
    ViewBag.Title = "Create";

It shows error on SurveysServiceReference that service reference cannot found.

I have foloowing model for cretaing it.

using System;
using System.Runtime.Serialization;
using System.Collections.Generic;
namespace SurveysService.Models
    [DataContract(IsReference = true)]
    public class Survey
        public Survey()
            this.Topics = new List<Topic>();
        public int SurveyID { get; set; }
        public string Title { get; set; }
        public string CreatedBy { get; set; }
        public Nullable<System.DateTime> Date { get; set; }
        public virtual ICollection<Topic> Topics { get; set; }

plz give me direction to create a record in database.

Posted 30-Aug-12 3:05am
Updated 30-Aug-12 3:40am
Karthik. A 30-Aug-12 9:42am
Changing @model Surveys.SurveysServiceReference.Survey to @model SurveysService.Models.Survey should take care of that issue. You just have an incorrect namespace in your view.
Ritesh Rana 30-Aug-12 12:59pm
thanks its all done..
Sergey Alexandrovich Kryukov 18-Mar-13 10:12am
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership. And the fact you even self-accepted on formally is just outrageous, a sure way for a ban. I hope you won't do it after this warning.

Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Apart from the answer you were given, you should create viewmodels for your views, these encapsulate one or more model objects and other data that is specific to the view being created.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 30 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100