I wanna know if i can use mongodb like models (model classes) in my project (asp.net mvc 4 c#).
For example:
namespace Demo.Models
{
public class Model1
{
public int ID { get; set; }
public string Title { get; set; }
public DateTime ReleaseDate { get; set; }
public string Genre { get; set; }
public decimal Price { get; set; }
}
public class MovieDBContext : DbContext
{
public DbSet<Model1> models { get; set; }
}
}
Let’s say this is standard model for mssql database. Can i create models like this to use MongoDB collections, documents?
If yes, how? (if you can provide me with link of some examples).
Thanks.
Yes you can don’t forget to add BsonId attribute, because every object has to have his own unique id.
And example you can find here:
http://www.joe-stevens.com/2011/10/02/a-mongodb-tutorial-using-c-and-asp-net-mvc/