using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
namespace DotNetCore20.Web.Models
{
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser
{
/// <summary>
/// 微信Id
/// </summary>
public string WeChatId { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Text;
namespace DotNetCore20.Entity.Core
{
/// <summary>
/// DB表基底
/// </summary>
[Serializable]
public abstract partial class BaseEntity
{
/// <summary>
/// Id
/// </summary>
[DataMember]
public long Id { get; set; }
/// <summary>
/// DB 資料版號
/// </summary>
[Timestamp]
public byte[] RowVersion { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[DataMember]
public DateTime CreateTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[DataMember]
public DateTime UpdateTime { get; set; }
/// <summary>
/// 状态
/// </summary>
[DataMember]
public EnumState State { get; set; }
}
/// <summary>
/// 状态
/// </summary>
public enum EnumState
{
/// <summary>
/// 删除
/// </summary>
Delete = 1,
/// <summary>
/// 正常
/// </summary>
Normal = 0,
}
}
using DotNetCore20.Entity.Core;
using System;
using System.Runtime.Serialization;
namespace DotNetCore20.Entity
{
[DataContract]
public class UserExtend : BaseEntity
{
/// <summary>
/// 用户Id
/// </summary>
[DataMember]
public long UserId { get; set; }
/// <summary>
/// 昵称
/// </summary>
[DataMember]
public long NickName { get; set; }
}
}
using DotNetCore20.Entity;
using Microsoft.EntityFrameworkCore;
namespace DotNetCore20.DAL.DbContext
{
public class DotNetCoreDbContext : Microsoft.EntityFrameworkCore.DbContext
{
public DotNetCoreDbContext(DbContextOptions<DotNetCoreDbContext> options) : base(options)
{
}
public DbSet<UserExtend> UserExtend { get; set; }
}
}
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=DotNetCoreDefaultDb;Trusted_Connection=True;MultipleActiveResultSets=true",
"DotNetCoreConnection": "Server=(localdb)\\mssqllocaldb;Database=DotNetCoreDb;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}
//自定义数据库连接字符串
services.AddDbContext<DotNetCoreDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DotNetCoreConnection")));
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using DotNetCore20.Web.Data;
using DotNetCore20.Web.Models;
using DotNetCore20.Web.Services;
using DotNetCore20.DAL.DbContext;
namespace DotNetCore20.Web
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
//自定义数据库连接字符串
services.AddDbContext<DotNetCoreDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DotNetCoreConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有