asp.net mvc - How to add a tag class to database using Migrations -


i want create these classes , use migration update database . question :

how make posttagmap class ? , here photo of classes relation ..

classes picture

public class post {     public virtual int id     { get; set; }      public virtual string title     { get; set; }      public virtual string shortdescription     { get; set; }      public virtual string description     { get; set; }      public virtual string meta     { get; set; }      public virtual string urlslug     { get; set; }      public virtual bool published     { get; set; }      public virtual datetime postedon     { get; set; }      public virtual datetime? modified     { get; set; }      public virtual category category     { get; set; }      public virtual ilist<tag> tags     { get; set; } } 

and here tag class :

 public class tag {     public virtual int id     { get; set; }      public virtual string name     { get; set; }      public virtual string urlslug     { get; set; }      public virtual string description     { get; set; }      public virtual ilist<post> posts     { get; set; } } 

you don't need create posttagmap class, many many relationship handled navigation properties in case public virtual ilist<tag> tags { get; set; } post class , public virtual ilist<post> posts { get; set; } tag class. handled once run update-database


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -