using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using TR.Business.Model;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Infrastructure;
namespace Business.Model
{
public class ServiceBase : DbContext
{
public ServiceBase()
{
this.Database.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["connectionstring"].ToString();
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
private bool _IsValidate = true;
public bool IsValidate
{
set
{
_IsValidate = value;
}
}
protected override bool ShouldValidateEntity(DbEntityEntry entityEntry)
{
return _IsValidate;
}
}
}
My Tech Blogs MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
ESA
0 Points
30 Posts
[MVC 3] Plugin Architecture with Data access
May 16, 2012 07:21 AM|LINK
I followed this guide to build a Plugin architecture ...
http://www.codeproject.com/Articles/358360/NET-4-0-ASP-NET-MVC-3-plug-in-architecture-with-e
Then my problem is:
How can i make a data access to use by plugin??
There are any tutorial to make this???
Thanks in advance
ignatandrei
All-Star
135047 Points
21654 Posts
Moderator
MVP
Re: [MVC 3] Plugin Architecture with Data access
May 16, 2012 08:59 AM|LINK
You can put into a database and read from there.
ESA
0 Points
30 Posts
Re: [MVC 3] Plugin Architecture with Data access
May 16, 2012 09:52 AM|LINK
The plugin architecture work fine ...
The application read all plugin a i can use them from all places ....
my problem is this:
The Plugin A have is table (ex tablea) and must have his unit of work to access data in table
The Plugin b have is table (ex tableb) and must have his unit of work to access data in table
... etc
now i would like to make a generic project for unit of work to access data ... and use it from all plugins to access to their tables
Thanks
amitpatel.it
Star
7956 Points
1865 Posts
Re: [MVC 3] Plugin Architecture with Data access
May 16, 2012 09:57 AM|LINK
I have add one services layer to interact with database by using of entity frameowrk. refer below link
http://amitpatelit.com/2011/07/22/add-service-layer-in-mvc/
Let me know if you have any questions on this.
MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
ignatandrei
All-Star
135047 Points
21654 Posts
Moderator
MVP
Re: [MVC 3] Plugin Architecture with Data access
May 16, 2012 09:57 AM|LINK
Sharing connection string is enough. Each plugin knows their tables.
ESA
0 Points
30 Posts
Re: [MVC 3] Plugin Architecture with Data access
May 16, 2012 10:05 AM|LINK
all my plugin have controller, model and views ....
and i would like to make one generic database access that i can use into all plugin ...
@amitpatel.it: It work with plugin architectures??
amitpatel.it
Star
7956 Points
1865 Posts
Re: [MVC 3] Plugin Architecture with Data access
May 16, 2012 11:01 AM|LINK
I have added common service class in post ..Please look into this ..
http://amitpatelit.com/2011/07/22/add-service-layer-in-mvc/
common service class.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Configuration; using TR.Business.Model; using System.Data.Entity; using System.Data.Entity.ModelConfiguration.Conventions; using System.Data.Entity.Infrastructure; namespace Business.Model { public class ServiceBase : DbContext { public ServiceBase() { this.Database.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["connectionstring"].ToString(); } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); } private bool _IsValidate = true; public bool IsValidate { set { _IsValidate = value; } } protected override bool ShouldValidateEntity(DbEntityEntry entityEntry) { return _IsValidate; } } }MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
bruce (sqlwo...
All-Star
36852 Points
5446 Posts
Re: [MVC 3] Plugin Architecture with Data access
May 16, 2012 01:34 PM|LINK
as the plugin is a varient of the factory model, you should use a factory model, say IOC (which was designed for plugins) to access the database.