| 1234567891011121314151617181920212223242526272829303132 |
- using System;
- using System.Collections.Generic;
- using System.Data.Entity;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using ConsoleHttp.Model;
- using MqttMsgServer.Model;
- namespace MqttMsgServer.Dao
- {
- public class ApplicationDbContext:DbContext
- {
-
- public ApplicationDbContext():base(AppSetting.GetValue("SqlServerConnectionString"))
- {
- // Database.SetInitializer(new DropCreateDatabaseIfModelChanges<ApplicationDbContext>());
- }
- public IDbSet<ClientInfos> ClientInfos { get; set; }
- public IDbSet<ReceiveMessageRecord> ReceiveMessageRecords { get; set; }
- protected override void OnModelCreating(DbModelBuilder modelBuilder)
- {
-
- base.OnModelCreating(modelBuilder);
- modelBuilder.Entity<ClientInfos>().Property(i=>i.Id).HasMaxLength(50);
- modelBuilder.Entity<ReceiveMessageRecord>().Property(i=>i.Id).HasMaxLength(50);
- }
- }
- }
|