CREATE DATABASE TestNetCoreEF
GO
USE TestNetCoreEF
GO
CREATE TABLE Student(
ID int identity primary key,
Name nvarchar(50),
Age int
)
INSERT INTO Student VALUES('Bear',18)
INSERT INTO Student VALUES('Frank',20)
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
………….
}
Scaffold-DbContext "{Your DB connect string}" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
optionsBuilder.UseSqlServer(@"{your sql connect string}");
}
public static string ConnectionString { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(ConnectionString);
}
"ConnectionStrings": {
"TestNetCoreEF": "Data Source={your sql server host address};Initial Catalog=TestNetCoreEF;user id={your username};password={your password};"
},
{
"ConnectionStrings": {
"TestNetCoreEF": "Data Source={your sql server host address};Initial Catalog=TestNetCoreEF;user id={your username};password={your password};"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
public void ConfigureServices(IServiceCollection services)
{
//config the db connection string
TestNetCoreEFContext.ConnectionString = Configuration.GetConnectionString("TestNetCoreEF");
// Add framework services.
services.AddMvc();
}
Models.TestNetCoreEFContext context = new Models.TestNetCoreEFContext(); var StudentList = context.Student.ToList();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有