ASP.NET MVC 4得到错误"异常已被调用&QUOT目标抛出; [英] ASP.NET MVC 4 getting error "Exception has been thrown by the target of an invocation"

查看:146
本文介绍了ASP.NET MVC 4得到错误"异常已被调用&QUOT目标抛出;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面Model类MVC和同样的事儿。的使用组合键在其与两个两列MS SQL Server数据库确实是PK,FK但我在 InitializeSimpleMembershipAttribute 像类异常被抛出由调用的目标请帮我拿到了如何创建。
这是我的模型类

  [表(webpages_UsersInRoles)]
    公共部分类UsersInRoles
    {
        [列(订单= 0)]
        公众诠释角色ID {搞定;组; }
        公共虚拟NewRoles角色{搞定;组; }        [列(订单= 1)]
        公众诠释用户ID {搞定;组; }
        公共虚拟用户配置的UserProfiles {搞定;组; }
    }


解决方案

你为什么这样做?你不需要这个定义自己。如果你使用的AccountController 键,如果你使用 WebSecurity 角色此表为您在SimpleMemberShipInitializer过滤器创建的。而你只需要使用内置的为您提供了与SimpleMembership提供商功能。

总之,你不需要定义这个表,国际海事组织是你有这些问题的原因。

I'm Using Composite keys in below Model class of mvc and same thing.I did in MS SQL Server database having two columns with both are PK,FK but i am getting error in InitializeSimpleMembershipAttribute class like "Exception has been thrown by the target of an invocation" please help me to get how to create. This is my model class

 [Table("webpages_UsersInRoles")]
    public partial class UsersInRoles
    {
        [Column(Order = 0)]
        public int RoleId { get; set; }
        public virtual NewRoles roles { get; set; }

        [Column(Order = 1)]
        public int UserId { get; set; }
        public virtual UserProfile UserProfiles { get; set; }      
    }

解决方案

why you doing that? you dont need to define this yourself. if you use AccountController and if you use WebSecurity Role this table is created for you in SimpleMemberShipInitializer filter. and you just need to use the built in functionality provided for you with SimpleMembership provider.

in short, you dont need to define this table which IMO is the reason you having these problems.

这篇关于ASP.NET MVC 4得到错误"异常已被调用&QUOT目标抛出;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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