Software consultant, Developer, Codder : SharePoint, Office 365, ASP.NET, MVC, SharePoint, Javascript, JQuery, Ember JS, Angular JS, Entity Framework, Linq, HTML5, DotnetNuke, codding philosophy, blogger 7+ experience in codding and developing web applications, Code 4 Help..
[Table("ProjectData")] public class Project { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } }
public class DATABContext : DbContext { public DATABContext() : base("ReportDB") { this.Database.CreateIfNotExists(); } public DATABContext(string ConnectionString) : base(ConnectionString) { this.Database.CreateIfNotExists(); } public DbSet[Product] Products { get; set; } }
public class Default1Controller : Controller { private DATABContext db = new DATABContext(); // // GET: /Default1/ public ViewResult Index() { return View(db.Products.ToList()); } }
Connection string : By code we can set connection string using properties Database.DefaultConnectionFactory = new SqlConnectionFactory("Data Source=RANMAL; Integrated Security=True; MultipleActiveResultSets=True");
No comments:
Post a Comment