views:

40

answers:

1

I am writing a blog using ASP.NET MVC2 and using EF4 as the ORM. I want to use Tags for navigation instead of traditional categories.

Tables:

Post Table
- Id
- Title
- Body
- Slug
- PostDate


PostTags Table
- PostId
- TagId

Tags Table
- Id
- TagName

I want to be able to get a Post object that includes a list of associated Tags. I am new to ASP.NET and MVC so any help would be great!

+1  A: 

In the Entity Framework designer, associations can be created between your entities.

If you are using an existing database as your model, make sure that you have foreign keys defined to describe the relationship between the rows in your tables. This will allow the Entity Framework to realize the entity associations that should be created in the model and provide the proper object mapping.

Each Tag object would have a collection of Posts and each Post object would have a collection of Tags.

JonathanK