Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:13:03+00:00 2026-05-25T13:13:03+00:00

I have a class User and then another Type UserSpecial with some special user

  • 0

I have a class User and then another Type UserSpecial with some special user properties.
I pass it in razor to the partial method class to create the UserSpecial form which expects an object of type User Special but i get an error.

@model User
    @using (Html.BeginForm())
    { 

        @Html.ValidationSummary(true)
        <fieldset>
            @Html.Partial("../UserSpecial/_CreateOrEdit", Model.UserSpecial)
            <p class="submit clear">
                <input type="submit" value="Register" />
            </p>
        </fieldset>
    }
</div>

Error i get –

The model item passed into the dictionary is of type ‘System.Data.Entity.DynamicProxies.User_AC9DED50C9495788046D6BFA3B90DDFC6AD2884157CF23C91FCB3B7A55F70B18’, but this dictionary requires a model item of type ‘UserSpecial’.

What am i doing wrong here?

From my controller i just pass the current User Object that i have stored in the session state.

Controller –

 public ActionResult Register()
        {
            return View(userRepository.Current);
        }

Here Current is of type “User”

Model –

public partial class User
    {
        public User()
        {
        }

        public int UserID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Sex { get; set; }
        public System.DateTime CreateDate { get; set; }
        public string Email { get; set; }
        public string HomeTown { get; set; }
        public short UserType { get; set; }

        public virtual UserSpecial UserSpecial { get; set; }
    }

Model Declaration for _CreateOrEdit is

@model UserSpecial
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:13:04+00:00Added an answer on May 25, 2026 at 1:13 pm

    No idea what userRepository.Current is but it seems that it doesn’t correctly/eagerly load the UserSpecial property. Why don’t you use view models? Why are you passing domain entity models to your views? That’s bad practice. You should define view models that contain only the data that’s required by your view and then in your controller action map between your domain models and the corresponding view model which will be passed to the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we had a heated discussion about a method name. We have a class User
I have some logic, which defines and uses some user-defined types, like these: class
I have dbml with single table users i want add partial class for User
I have a class User with one field called birthDate which is a java.sql.Date
I have a class: public class User { public virtual int Id { get;
I have this Class: public class User { public string id{ get; set; }
I have a class called User with static function loginRequired(), which returns false if
I have following code class User attr_accessor :name end u = User.new u.name =
I have two models: class User end class Message belongs_to :sender, :class_name=> 'User' belongs_to
I have 3 models class User < ... belongs_to :language has_many :posts end class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.