This repository has been archived by the owner on Apr 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 318
quickstart signalr
郭明锋 edited this page Oct 16, 2015
·
1 revision
- 打开Nuget程序包控制台或在资源管理器右键“管理Nuget程序包”,引用程序包
- 向工程添加 OSharp.Web.SignalR
- 向工程添加 OSharp.Autofac.SignalR(或其他IoC实现)
- 在Web.Config文件中添加
name="default"
的数据库连接串
<connectionStrings>
<add name="default" connectionString="Data Source=.; Integrated Security=True; Initial Catalog=OSharp.Default; Pooling=True; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
- 添加EntityInfo与Function实体类的实体映射配置
public class EntityInfoConfiguration : EntityConfigurationBase<EntityInfo, Guid>
{ }
public class FunctionConfiguration : EntityConfigurationBase<Function, Guid>
{ }
- 在Global的Application_Start方法中添加初始化代码
IServicesBuilder builder = new ServicesBuilder();
IServiceCollection services = builder.Build();
services.AddDataServices();
IFrameworkInitializer initializer = new FrameworkInitializer();
initializer.Initialize(new SignalRAutofacIocBuilder(services));
- 或者OWin方式,在Startup类的Configuration方法中添加初始化代码
IServicesBuilder builder = new ServicesBuilder();
IServiceCollection services = builder.Build();
services.AddDataServices();
app.UseOsharpSignalR(new SignalRAutofacIocBuilder(services));
- 运行项目,即可完成初始化,将会自动生成相应的数据库,并初始化好需要的数据
power by @osharp-team (osharp.org)