1440 900高清壁纸,曾沛慈的老公,安扎克饼干
如果要在程序中使用dbcontext,则需要先在nuget中安装microsoft.entityframeworkcore.sqlserver
using consoleapp1.entityframeworkcore; using microsoft.entityframeworkcore; using microsoft.extensions.dependencyinjection; using system; using consoleapp1.businesslogic; namespace consoleapp1 { class program { static void main(string[] args) { startup(); console.writeline("hello world!"); } private static void startup() { var services = new servicecollection(); var connectionstring = "data source=localhost;initial catalog=testdb;user id=sa;password=123;"; services.adddbcontext<mydbcontext>(options => options.usesqlserver(connectionstring)); services.addscoped<idatabasebo, databasebo>(); var provider = services.buildserviceprovider(); using (var servicescope = provider.createscope()) { var serviceprovider = servicescope.serviceprovider; var databasebo = serviceprovider.getservice<idatabasebo>(); databasebo.generatedata(); } } } }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论