程序包管理器控制台中的Update-Database失败.我使用了Entity Framework 6.x和代码优先方法.错误是
"数据库中已经有一个名为'AboutUs'的对象."
我怎么解决这个问题?
internal sealed class Configuration
: DbMigrationsConfiguration<Jahan.Blog.Web.Mvc.Models.JahanBlogDbContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = false;
}
protected override void Seed(Jahan.Blog.Web.Mvc.Models.JahanBlogDbContext context)
{
}
}
Run Code Online (Sandbox Code Playgroud)
我的DbContext是:
public class JahanBlogDbContext : IdentityDbContext<User, Role, int, UserLogin, UserRole, UserClaim>
{
public JahanBlogDbContext()
: base("name=JahanBlogDbConnectionString")
{
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<JahanBlogDbContext>());
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Entity<Comment>().HasRequired(t => t.Article).WithMany(t => t.Comments).HasForeignKey(d => d.ArticleId).WillCascadeOnDelete(true);
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>().ToTable("User");
modelBuilder.Entity<Role>().ToTable("Role");
modelBuilder.Entity<UserRole>().ToTable("UserRole");
modelBuilder.Entity<UserLogin>().ToTable("UserLogin");
modelBuilder.Entity<UserClaim>().ToTable("UserClaim");
}
public virtual DbSet<Article> Articles { get; set; }
public …
Run Code Online (Sandbox Code Playgroud) database entity-framework ef-code-first ef-migrations entity-framework-6
我在我的网站(网络应用程序)中使用了Umbraco 4.11.6.我的网站在localhost中工作(从Visual Studio 2012和IIS(v7)测试)但是当我从互联网空间运行它时出现错误.错误是:
程序集加载跟踪:以下信息有助于确定无法加载程序集"System.Web.Razor"的原因.
警告:装配绑定日志记录已关闭.要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1.注意:程序集绑定失败日志记录会导致一些性能损失.要关闭此功能,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog].
堆栈跟踪:
[FileLoadException:无法加载文件或程序集'System.Web.Razor'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)]
[FileLoadException:无法加载文件或程序集'System.Web.Razor,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+0
System.Reflection.RuntimeAssembly .InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection)+242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMark,Boolean forIntrospection)+17 System.Reflection.Assembly.Load(String assemblyString)+35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+122[ConfigurationErrorsException:无法加载文件或程序集'System.Web.Razor,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+12761078
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+503 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+334
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath)+203
System.Web.Compilation.BuildManager.ExecutePreAppStart()+ 155
System.Web.Hosting .HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException)+1151[HttpException(0x80004005):无法加载文件或程序集'System.Web.Razor,Version = 2.0.0.0,Culture = …
我正在我的项目中使用umbraco 4.11.3.我的项目工作得很好,在Windows 7上运行并从visual studio 2012运行.但是当它从Visual Studio 2012运行时它在Win 8中不起作用!
错误是:
无法加载文件或程序集'System.Web.Mvc,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:System.IO.FileLoadException:无法加载文件或程序集'System.Web.Mvc,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
来源错误:
在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
程序集加载跟踪:以下信息有助于确定无法加载程序集"System.Web.Mvc,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"的原因.
===预绑定状态信息===日志:用户= Jahan-PC\jahan日志:DisplayName = System.Web.Mvc,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35(完全指定)日志:应用平台=文件:/// G:/20130204/SourceCode/Defraz.Movafaqiyat.WebApp/Defraz.Movafaqiyat.WebApp/ LOG:初始PrivatePath = G:\ 20130204 \源码\ Defraz.Movafaqiyat.WebApp\Defraz.Movafaqiyat.WebApp\bin调用程序集:ClientDependency.Core.Mvc,Version = 1.5.1.0,Culture = neutral,PublicKeyToken = null.===日志:此绑定在默认加载上下文中启动.日志:正在使用应用程序配置文件:G:\ 20130204 \源码\ Defraz.Movafaqiyat.WebApp\Defraz.Movafaqiyat.WebApp\web.config中LOG:使用主机配置文件:C:\用户\汗\文件\ IISExpress \配置\ ASPNET .config日志:使用C:\ Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config中的计算机配置文件.日志:后政策参考:System.Web.Mvc,版本= 2.0.0.0,文化=中性公钥= 31bf3856ad364e35 LOG:尝试新的URL文件下载:/// C:/用户/汗/应用程序数据/本地/温度/ Temporary ASP.NET Files/root/bc5b37d0/42db0b24/System.Web.Mvc.DLL.日志:尝试新的URL文件下载:/// C:/用户/汗/应用程序数据/本地/温度/ ASP.NET临时文件/根/ bc5b37d0/42db0b24/System.Web.Mvc/System.Web.Mvc.dll程序.日志:新的URL文件的尝试下载:/// G:/20130204/SourceCode/Defraz.Movafaqiyat.WebApp/Defraz.Movafaqiyat.WebApp/bin/System.Web.Mvc.DLL.警告:比较程序集名称导致不匹配:主要版本错误:无法完成程序集的设置(hr = 0x80131040).探测终止.
堆栈跟踪:
[FileLoadException:无法加载文件或程序集'System.Web.Mvc,Version = …
我使用ASP.NET Identity 2来创建角色,但结果HttpContext.GetOwinContext().GetUserManager<AppRoleManager>()
为null.
然后我无法创建角色.
我怎么解决这个问题?
public class MVCController : Controller
{
public MVCController()
{
}
public AppRoleManager RoleManager // returns null ?!
{
get
{
return HttpContext.GetOwinContext().GetUserManager<AppRoleManager>();
}
}
public User CurrentUser
{
get
{
string currentUserId = User.Identity.GetUserId();
User currentUser = DataContextFactory.GetDataContext().Users.FirstOrDefault(x => x.Id.ToString() == currentUserId);
return currentUser;
}
}
public IAuthenticationManager AuthManager
{
get
{
return HttpContext.GetOwinContext().Authentication;
}
}
public AppUserManager UserManager
{
get
{
return HttpContext.GetOwinContext().GetUserManager<AppUserManager>();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的控制器:
public class RoleAdminController : MVCController …
Run Code Online (Sandbox Code Playgroud) 我想更新我的软件包,但我遇到了一些这样的错误:
错误是:
错误 NU1202 Package Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 与 net50 (.NETFramework,Version=v5.0) / win7-x86 不兼容。包 Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 支持:netstandard2.1 (.NETStandard,Version=v2.1) API E:...\API\API.csproj 1
API.csproj 文件:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
<PackageReference Include="CloudinaryDotNet" Version="1.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-preview.8.20407.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0-preview.8.20407.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-preview8" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
C:\WINDOWS\system32>dotnet --info .NET SDK(反映任何 global.json):
版本:5.0.100-rc.1.20452.10
提交:473d1b592e运行时环境:
操作系统名称:Windows
操作系统版本:10.0.17763 操作系统平台:Windows …
如何在Prisma.js
不重置整个数据库的情况下对数据库进行更改?
如果我使用过这个命令
npx prisma migrate dev --name role-makeOptional-NormalizedName
Run Code Online (Sandbox Code Playgroud)
我将丢失数据库中的所有数据,但不会丢失我的数据。
就我而言,我想更改String
为文件String?
中schema.prisma
NormalizedName String? @unique @db.VarChar(64)
Run Code Online (Sandbox Code Playgroud)
是否有适当的命令来避免丢失数据?
Umbraco HttpContext.Current.Cache
和ApplicationContext.ApplicationCache.RuntimeCache
Umbraco有什么不同?哪一个在效率方面更好用?
我用过Umbraco 7.4.x
我的项目和ASP.NET MVC
.在我的项目中,我有一个可以包含这么多项目的产品列表,因此我想使用缓存.具体来说,我想将我的数据放在缓存中,当一个新项添加到Products
节点时,缓存会自动更新.我该如何实现它?
修改:请给我一个实现,详细说明我的代码.
Products.cshtml:
@using Jahan.Handicraft.Model.UModel.URenderModel
@using Jahan.Handicraft.Model.UModel
@inherits Umbraco.Web.Mvc.UmbracoViewPage<BaseRenderModel<Jahan.Handicraft.Model.UModel.Products>>
@foreach (var prod in Model.Model.ProductList.Skip((page - 1) * pageSize).Take(pageSize))
{
@*<div>LOAD DATA</div>*@
}
Run Code Online (Sandbox Code Playgroud)
ProductsController.cs:
namespace Jahan.Handicraft.Web.Mvc.UmbracoCms.App.Controllers
{
public class ProductsController : BaseRenderMvcController<Products>
{
// GET: Products
public override ActionResult Index(RenderModel model)
{
return base.Index(Instance);
}
}
}
Run Code Online (Sandbox Code Playgroud)
BaseRenderMvcController.cs:
public class BaseRenderMvcController<TBaseEntity> : RenderMvcController where TBaseEntity : BaseEntity
{
private BaseRenderModel<TBaseEntity> _instance;
public BaseRenderModel<TBaseEntity> Instance
{
get
{
if …
Run Code Online (Sandbox Code Playgroud) 在Visual Studio 2017
,我在与之相关的所有项目中都出错ASP.NET Core 2
.说的是:
无法运行您的项目.未定义runcommand属性
即使我卸载VS并再次安装它,但我仍然有这个问题.我测试了VS的默认项目模板,但那些也没有正确执行.请帮我.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Folder Include="Views\Product\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud) visual-studio asp.net-core visual-studio-2017 asp.net-core-2.0
我是 Angular 的新手。
我怎么解决这个问题?
我已经安装Angular CLI: 11.0.7
并Node: 12.18.4
错误:
错误:src/app/_services/account.service.ts:19:7 - 错误 TS2345:“OperatorFunction<User, void>”类型的参数不可分配给“OperatorFunction<Object, void>”类型的参数。“对象”类型可分配给很少的其他类型。您是想改用“any”类型吗?“对象”类型缺少“用户”类型中的以下属性:用户名、令牌
Run Code Online (Sandbox Code Playgroud)19 map((response: User) => { ~~~~~~~~~~~~~~~~~~~~~~~~~ 20 const user = response; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... 24 } ~~~~~~~~~ 25 }) ~~~~~~~~
账户.service.ts
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import {map} from 'rxjs/operators';
import { User } from '../_models/user';
import { ReplaySubject } from 'rxjs';
export class AccountService {
baseUrl = 'https://localhost:5001/api/';
private currentUserSource = new ReplaySubject<User>(1);
currentUser$ = …
Run Code Online (Sandbox Code Playgroud) 我有一个问题,对我来说这很奇怪!我在两个不同的地方有2个解决方案.它们两个相似,但其中一个比另一个更老.当我在它上面运行一个Kendo Grid时,新版本出现了问题.但是当我在新版本旁边打开旧版本的解决方案时,我强调只是打开没有运行,新版本会没问题!对我来说,如何解决这个问题以及另一个解决方案如何通过打开解决方案来解决这个问题非常奇怪?我认为有些东西已经损坏但我不知道,那是什么.我怎么解决这个问题?
我已经为Asp.net MVC使用了Visual Studio 2013,C#和Kendo.
Jahan.Blog.sln文件:(新版本)
Microsoft Visual Studio Solution File, Format Version 12.00
Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Model.DbFirst", "Applications\Jahan.Blog.Model.DbFirst\Jahan.Blog.Model.DbFirst.csproj", "{EE04EA76-1CFE-4484-B6C5-7C5232B3F1C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Model", "Applications\Jahan.Blog.Model\Jahan.Blog.Model.csproj", "{944336E2-DC84-451C-BB1D-86C619A1770D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Web.Mvc", "Applications\Jahan.Blog.Web.Mvc\Jahan.Blog.Web.Mvc.csproj", "{09F658AE-5DDD-44DA-950D-6C3CF1259206}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Web.TestHtml", "Applications\Jahan.Blog.Web.TestHtml\Jahan.Blog.Web.TestHtml.csproj", "{69D02E00-1663-464B-B07A-C129B8D29C8D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.HtmlPage", "Applications\Test.HtmlPage\Test.HtmlPage.csproj", "{5C1E487D-6421-470E-9398-11CB230D5435}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Blog", "Blog", "{790963C2-9AB6-440E-96B3-48A29CF9663A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProjectsForTest", "ProjectsForTest", "{F7F4128F-4141-434A-9655-8BA7B6806570}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{C3F7006C-B13C-447E-BABB-6561B38EB71B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Infrastructure.DataAccess", "Applications\Jahan.Infrastructure.DataAccess\Jahan.Infrastructure.DataAccess.csproj", "{511E08CF-B782-49AF-BA10-E52BCDA4140D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = …
Run Code Online (Sandbox Code Playgroud) asp.net-mvc runtime visual-studio kendo-grid kendo-asp.net-mvc
asp.net-mvc ×4
c# ×3
umbraco ×3
asp.net ×2
.net-5 ×1
angular ×1
asp.net-core ×1
caching ×1
database ×1
deployment ×1
identity ×1
kendo-grid ×1
node.js ×1
nuget ×1
owin ×1
performance ×1
prisma ×1
prisma2 ×1
roles ×1
runtime ×1
typescript ×1
umbraco7 ×1