又一个MVC 多租户

来源:互联网 发布:单片机培训内容 编辑:程序博客网 时间:2024/05/03 13:27

1。看起来是个不著名的解决方案,没啥人气,权当学习之用:

http://code.google.com/p/multimvc/wiki/WhereToStart

 public static class TenantContext
    {
        public static string ConnectionString { get; }
        public static string DbName { get; }
        public static string Language { get; }
        public static string TenantKey { get; }

        public static void SetTenantContextProvider(ITenantContextProvider provider);
    }

以上是租户对象的基本信息,可见是采用different db的多租户模式的。 DBName/Connectionstring也不同,此类问题是,没有统一管理需求的,可以如此做,比如动态创建tenant,收集tenant下面的数据,合并到一起分析

核心思想一致,就是一个tenatContext包含了该租户的详细配置等

Implement the Ressource functionality.Ressources is a Key Value dictionary.Ressources should dependent on current language & tenant.Ressources are provided by a RessourceProviderService.Ressources are loaded by the ExtensionFactory into a dictionary.Ressources are available through the TenantContext.

 Nhibernate错误

 

NHibernate.MappingException was unhandled by user code
  Message=No persister for: BA.MultiMvc.Framework.NHibernate.Resource
  Source=NHibernate
  StackTrace:
       at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName)
       at NHibernate.Impl.SessionImpl.GetEntityPersister(String entityName, Object obj)
       at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
       at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
       at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
       at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)
       at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)
       at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
       at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
       at NHibernate.Impl.SessionImpl.Save(Object obj)
       at BackToOwner.Web.Setup.NHResourceCreation.InsertOrUpdate() in C:\Dev\MultiMvc\Framework\NHibernate\NHResourceCreation.cs:line 32
       at BackToOwner.Golf.Web.MvcApplication.InsertResources()in C:\workingFolder\web开发资料\MultiMVC-0.0.1.0\MultiMVC-0.0.1.0\Sample\BackToOwner.Golf.Web\Global.asax.cs:line 180
       at BackToOwner.Golf.Web.MvcApplication.Application_BeginRequest(Object sender, EventArgs e) in C:\workingFolder\web开发资料\MultiMVC-0.0.1.0\MultiMVC-0.0.1.0\Sample\BackToOwner.Golf.Web\Global.asax.cs:line 126
       at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
  InnerException:
====解决方法:really?

57down voteaccepted

Sounds like you forgot to add a mapping assembly to the session factory configuration..

If you're using app.config...

.. <property name="show_sql">true</property><property name="query.substitutions">true1, false 0, yes'Y', no'N'</property><mapping assembly="Project.DomainModel"/><!-- Here--> </session-factory>. .

 

2。okay,看起来不容易的一个代码项目。再看另外一个多租户blog 系统,感觉是刚起步就停止了

http://mvcpress.codeplex.com/discussions/32167

 

3。看用了sql azure联邦的 MT方案,似乎应该是最新的了,可惜我们还不是用这套的。空了可以尝试下

http://shard.codeplex.com/

Project Description
This is a sample application demonstrating the use of SQL Azure Federations in a multi-tenant solution.

The Cloud Ninja - SQL Azure Federations Project is a sample demonstrating the use of SQL Azure Federations in creating multi-tenant solutions. SQL Azure Federations can be a useful feature in migrating existing single tenant solutions to multi-tenant cloud solutions, as well as building new multi-tenant internet scale solutions. In this project we demonstrate the migration of an existing solution to SQL Azure Federations and further leveraging SQL Azure Federation features in our multi-tenant solutions.

The Cloud Ninja Multi-tenant task application makes use of SQL Azure Federations filtered connections in working with tenant data. A connection is opened to a SQL Azure Federations database, the initial connection is opened on the root database. We can then use the "USE FEDERATIONS" statement to route our connection to the correct federation member containing the tenant data, and enable filtering, which will scope our connection to an individual automic unit (unique tenant in our case). We can use the "USE FEDERATIONS" statement to easily route our connection to the root and any federation member as needed.

原创粉丝点击