草庐IT

multi-model-database

全部标签

c# - 在 Database First 中更改实体和属性名称

我正在启动一个新应用程序,该应用程序必须使用现有数据库,该数据库使用一些在.net中非常烦人的命名约定(表名以指定表的业务域的几个三元组开头,列名以表开头八卦,三卦都是大写的,用下划线等分隔,)。我想做的是编写一个简单的重命名规则(这就像找到最后一个下划线并获取后面的所有内容一样简单)并将其应用到EntityFramework中。我真的不想在编辑器中一个一个地编辑名字,尤其是因为数据库可能会改变,我不想重复多次。我正在使用DatabaseFirst(因为数据库已经存在并且它是“主数据库”)和EF4.xDbContextGenerator,它开箱即用(尽管类和属性的命名很糟糕)。我编辑了

c# - Ninject multi-injection 并没有我想象的那么贪心!怎么会?

如果我有一个类,其中的ctor设置为像这样的多重注入(inject):publicShogun(IEnumerableallWeapons){this.allWeapons=allWeapons;}绑定(bind)设置如下:Bind().To();Bind().To().WhenInjectedInto();那么我希望build幕府将军时两种武器都已注入(inject)?但事实并非如此-它只会获得Dagger。如果我像这样添加进一步的绑定(bind):Bind().To();Bind().To().WhenInjectedInto();Bind().To().WhenInjectedI

c# - EntityFramework 测试初始化​​错误 : CREATE DATABASE statement not allowed within multi-statement transaction

我正在尝试构建一个快速测试,每次运行时都会删除并重新创建数据库。我有以下内容:[TestClass]publicclassPocoTest{privateTransactionScope_transactionScope;privateProjectDataSource_dataSource;privateRepository_repository=newRepository();privateconststring_cstring="DataSource=.;InitialCatalog=test_db;Trusted_Connection=True";[TestInitialize

c# - 在 "CREATE TABLE permission denied in database"ASP.NET - MVC4 中列出表结果

我正在使用ASP.NETMVC4-c#连接到实时数据库并列出结果,但是当我查看页面时它返回以下错误:CREATETABLEpermissiondeniedindatabase'DatabaseName'.Description:Anunhandledexceptionoccurredduringtheexecutionofthecurrentwebrequest.Pleasereviewthestacktraceformoreinformationabouttheerrorandwhereitoriginatedinthecode.ExceptionDetails:System.Dat

c# - MVC 错误 : The model item passed into the dictionary is null

我只是想建立一个View,但我收到以下错误:System.InvalidOperationException:Themodelitempassedintothedictionaryisnull,butthisdictionaryrequiresanon-nullmodelitemoftype'System.DateTime现在,我知道为什么会出现这种情况,数据库中的特定字段是空值,但它应该是空值,因为这是稍后编辑的内容。这是我的代码:ActionpublicActionResultView(Int64?Id){ModelContainerctn=newModelContainer();

c# - 当部分 View 位于共享文件夹中时,ASP.NET MVC '@model dynamic' 无法识别模型属性

不重复:MVCRazordynamicmodel,'object'doesnotcontaindefinitionfor'PropertyName'根据那里的答案,AccordingtoDavidEbbo,youcan'tpassananonymoustypeintoadynamically-typedviewbecausetheanonymoustypesarecompiledasinternal.SincetheCSHTMLviewiscompiledintoaseparateassembly,itcan'taccesstheanonymoustype'sproperties.为什

c# - EF 5 代码迁移错误 : "There is already an object named _____ in the database"

在进行EF5代码迁移时遇到了一个反复出现的奇怪问题,现在让我无法工作。尝试运行update-database并收到此错误:Thereisalreadyanobjectnamed'RequestStatus'inthedatabase.详细的日志转储:PM>update-database-vUsingStartUpproject'LicensingWorkflow'.UsingNuGetproject'LicensingWorkflow'.Specifythe'-Verbose'flagtoviewtheSQLstatementsbeingappliedtothetargetdataba

c# - ASP MVC 中的 Multi-Tenancy

恐怕又是一个Multi-Tenancy帖子。我只是找不到解决我问题的好方法,我已经阅读了所有关于ASPMVCMulti-Tenancy的精彩文章,但我仍然需要一些好的建议。我要为我的一位客户创建公司形象。他们的公司结构就像一个主公司(前AcmeGroupLtd.)拥有其他几家公司(例如AcmeHoldingLtd、AcmeTechnologyLtd.、AcmeMaritimeLtd.等)。我想使用一个ASPMVC项目作为所有站点的容器,以减少所需的代码并使其保持干燥。我还希望所有网站都使用相同的成员(member)数据库。我的第一个想法是为每个子公司创建一个Controller文件夹,

c# - 无法使用 EFCore、EntityState.Modified : "Database operation expected to affect 1 row(s) but actually affected 0 row(s)." 编辑数据库条目

我将IdentityCore1.0与ASP.NETMVCCore1.0和EntityFrameworkCore1.0结合使用来创建一个简单的用户注册系统thisarticle作为起点,我正在尝试添加用户角色。我可以添加用户角色,但无法编辑它们。这是RolesController中的Edit操作:[HttpPost][ValidateAntiForgeryToken]publicIActionResultEdit(IdentityRolerole){try{_db.Roles.Attach(role);_db.Entry(role).State=Microsoft.EntityFrame

c# - "Data Source cannot be empty. Use :memory: to open an in-memory database"是什么意思?

我最近将我的SQLServer数据库转换为SQLite数据库。但是当我尝试使用.Open()打开我的SQLite时,它​​抛出了这个错误:DataSourcecannotbeempty.Use:memory:toopenanin-memorydatabase编辑:添加连接字符串:ConnectionString=@"DataSource=D:\XXX.db;Version=3";connection=newSQLiteConnection(connectionString);connection.Open();为什么我会得到这个?我将相同的SQLServer数据库转换为SQLCE和my