entity framework - ASP.NET Identity 2: trouble creating Fluent Code First relationships -


I am trying to create an ASP.NET identity DBCOnTech from scratch (IDECTED to get rid of depenency at BCCXTT & lt ; ...>)

Almost there ... but my EF code first fluent relationship is not yet true.

The table structure should will come in this form: Image details here Enter

but get more like the following:

Even after being clear HasForeignKey is clearly defined

My question is ... I have relationships Where's the wrong?

Thank you!

The following is the use of mapping:

  public class ApplicationDbContext: DbContext {... public ApplicationDbContext (): Base ("default connection") //, ThrowIfV1Schema: Incorrect {Database.SetInitializer & lt; ApplicationDbContext & gt; (New ApplicationDbInitializer ()); } ... Protected Override Zero OnModelCreating (System.Data.Entity.DbModelBuilderModelBuilder) {base.OnModelCreating (ModelBuilder); Modlbilder Configuration. Add (new identityRollMap ()); Modlbilder Configuration. Add (new identity usermap ()); Modlbilder Configuration. Add (New Identity User LoginMap ()); Modlbilder Configuration. Add (new identity usermap); Modlbilder Configuration. Add (new identity cart map ()); } ...} Public Category Identifier Customer Map: EntityTypeConfiguration & lt; IdentityUserClaim & gt; {Public Identification UserClaimMap () {this.HasKey (t = & gt; t.Id); this. Property (t = & gt; TUSID). ISRAEFair () Hasmaxleamth (128); This.ToTable ("Custom_UserClaims"); }} Public Class Identity User LoginMap: EntityTypeConfiguration & lt; IdentityUserLogin & gt; {Public identity-user login () {this.HasKey (t = & gt; new {t.UserId, t.LoginProvider, t.ProviderKey}); this. Property (t = & gt; T. Loginprovider). ISRAEFair () Hasmaxleamth (128); this. Property (T = & gt; T Provider Key). ISRAEFair () Hasmaxleamth (128); this. Property (t = & gt; TUSID). ISRAEFair () Hasmaxleamth (128); This.ToTable ("Custom_UserLogins"); }} Public category identity reelmap: EntityTypeConfiguration & lt; IdentityRole & gt; {Public identification map () {this.HasKey (t = & gt; t.Id); this. Property (t = & gt; tid) ISRQIRED () Hasmaxleamth (128); this. Property (T = & gt; T. Nom). ISRAEFair () Hasmax Lang (256); This.ToTable ("Custom_Roles"); This is .HasMany (x = & gt; x.Users). With partner () .HasForeignKey (x = & gt; x.RoleId); }} Public Class Identity User Map: EntityTypeConfiguration & lt; ApplicationUser & gt; {Public identification usermap () {this.HasKey (t = & gt; t.Id); this. Property (t = & gt; tid) ISRQIRED () Hasmaxleamth (128); this. Property (T = & gt; T. Email). Mascal Lamp (256); this. Property (T = & gt; T. Usernam). Necessary (). HasMaxLength (256); This.ToTable ("Custom_Users"); // Navigation: Claims: User can claim 1- (0- *) claims. It is very & lt; IdentityUserClaim & gt; (X = & gt; x.Claims). Mandatory () .asForeignKey (x = & gt; x.UserId) .WillCascadeOnDelete); // Navigation: Login: Users can log in 1- (0- *). Go to & lt; IdentityUserLogin & gt; (X = & gt; x.Logins). Essentials with () .HasForeignKey (x = & gt; x.UserId) .WillCascadeOnDelete (); // Navigation: Roles: // Interestingly, a * - * map description is not being used: this is the master. & Lt; IdentityUserRole & gt; (X = & gt; x.Roles). Mandatory () .asForeignKey (x => UserId) .WillCascadeOnDelete (wrong); }} Public Class IdentityRolar Map: EntityTypeConfiguration & lt; IdentityUserRole & gt; {Public IdentityAirolomap () {this.ToTable ("Custom_UserRoles") .HasKey (x = & gt; new {x.UserId, x.RoleId}); }}  

Oh, that's upset.

This works fine.

I do not use the drawing tool of many SQL Server, and I did not know that at some point I got this right ... but this picture was kept wrong, only because I They did not refresh the tables before selecting them. wastage of time!

Commenting on using one or two DBCentaxes as Eric has been suggested in the comments, I will think more about it. For now, I will play along with using a single DBCOntext as all the functionality works well.

Night


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -