小编E-B*_*Bat的帖子

问题安装实体框架7 RC1

我正在尝试将EF7 rc1安装到现有项目中:

PM> Install-Package EntityFramework.MicrosoftSqlServer -Pre

但是我收到以下错误:

安装失败.回滚...
项目'XYZ'中不存在包'Microsoft.Extensions.Logging 1.0.0-rc1-final'

在跟踪的最后,我得到了另一条消息:

Install-Package:无法添加对'System.Collections.Concurrent'的引用.请确保它在全局程序集缓存中.

我用google搜索并且可以看到Concurrent集合已经在dotnet中存在了一段时间,但我在开发框中没有这样的汇编.

更新:

在查询gac之后gacutil我意识到组件确实存在:

全局程序集缓存包含以下程序集:

System.Collections.Concurrent,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,processorArchitecture = MSIL

.net entity-framework visual-studio nuget .net-4.5.2

17
推荐指数
2
解决办法
2774
查看次数

实体框架6代码优先:将字符串属性的unicode设置为false

在我的模型中,我有一些用StringLength属性修饰的实体:

[StringLength(128)]    
public string FirstName { get; set; }
Run Code Online (Sandbox Code Playgroud)

此外,我已通过这种方式禁用所有字符串属性的unicode:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);
    modelBuilder.Properties<string>().Configure(p => p.IsUnicode(false));            
}
Run Code Online (Sandbox Code Playgroud)

问题是,在生成数据库模式时,使用上述属性修饰的所有字符串属性都会忽略此设置,从而为相应的数据库列生成nvarchar数据类型.在这种情况下,禁用unicode的正确方法是什么?

entity-framework ef-code-first

13
推荐指数
1
解决办法
1万
查看次数

Aspnet MVC 4 验证十进制数

我在应用程序中验证小数时遇到一些问题。例如,如果我在文本框中写入“14,25”(这对于我的文化而言是正确的),则客户端验证会失败。另外,如果我写 14.25,点将被删除,1425 将被放置在实体属性中,而且,在 SaveChanges 后,保存到数据库表的值是 999,99。需要关于这个问题的建议。这与我的其他问题相关: /sf/ask/1693045581/#24186535

编辑:添加代码,就这么简单,我想我没有必要,因为这必须是一个常见问题。

[DisplayFormat( DataFormatString = "{0:n2}", ApplyFormatInEditMode = true )]
        public decimal Peso { get; set; }

@Html.LabelFor(model => Model.Peso)
<div class="input-control text" data-role="input-control">
    @Html.EditorFor(model => Model.Peso)
    @Html.ValidationMessageFor(model => Model.Peso)
</div>
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc jquery jquery-validate unobtrusive-validation

5
推荐指数
1
解决办法
7073
查看次数

EF Core RC2 FinaI问题:没有为此DbContext配置数据库提供程序

用EF Core rc 2 final替换EF Core rc 1后,我们在调用GetService()方法时遇到无效的操作异常.这里的目标是从任何给定的DbSet获取相应的DbContext:

public static ObservableCollection<TEntity> Local<TEntity>(this DbSet<TEntity> set)
            where TEntity : class
{
            var context = set.GetService<DbContext>();
            ...
}
Run Code Online (Sandbox Code Playgroud)

异常完整消息:

没有为此DbContext配置数据库提供程序.可以通过覆盖DbContext.OnConfiguring方法或在应用程序服务提供程序上使用AddDbContext来配置提供程序.如果使用AddDbContext,那么还要确保您的DbContext类型在其构造函数中接受DbContextOptions对象,并将其传递给DbContext的基础构造函数.

我们实际上是在OnConfiguring中设置数据库提供程序:

protected override void OnConfiguring(DbContextOptionsBuilder builder)
{
    base.OnConfiguring(builder);
    var connStringBuilder = new SqlConnectionStringBuilder();
    connStringBuilder.UserID = "MyUserID";
    ...         
    builder.UseSqlServer(connStringBuilder.ConnectionString);
}
Run Code Online (Sandbox Code Playgroud)

所以似乎问题来自方法GetService()没有为给定的DbSet解析正确的DbContext实例?

.net c# entity-framework

5
推荐指数
1
解决办法
2417
查看次数

Linq:SqlFunctions.PatIndex vs string.Contains for string comparisson

相同查询的以下哪个版本的性能会更好:

版本1(string.Contains):

var query = db.Products
    .Where( p => p.Description.Contains( description ) );
Run Code Online (Sandbox Code Playgroud)

版本2(SqlFunctions.PatIndex):

var query = db.Products
    .Where( p => SqlFunctions.PatIndex("%" + description + "%",p.Description) > 0  );
Run Code Online (Sandbox Code Playgroud)

c# linq

4
推荐指数
1
解决办法
3831
查看次数

基于EF 6代码的迁移异常:Microsoft.VisualStudio.Data.Tools.Package不可序列化?

我有这个配置

internal sealed class Configuration :DbMigrationsConfiguration<IAS.Models.ApplicationDbContext> {
            public Configuration() {
                AutomaticMigrationsEnabled = false;
                ContextKey = "IAS.Models.ApplicationDbContext";
            }

            protected override void Seed( IAS.Models.ApplicationDbContext context ) {
                var baseDir = AppDomain.CurrentDomain.BaseDirectory;
                context.Database.ExecuteSqlCommand(File.ReadAllText(baseDir + "\\MyInsertScriptsql"));
        }
    }
Run Code Online (Sandbox Code Playgroud)

当运行upate-dataabase时,我得到以下异常

Excepciónalllamar a"SetData"con los argumentos"2":"El tipo'Microsoft.VisualStudio.Data.Tools.Package.Internal.OAProject'del ensamblado'Microsoft.VisualStudio.Data.Tools.Pa ckage,Version = 11.1. 0.0,Culture = neutral,PublicKeyToken =b03f5f7f11d50a3a'noestámarcadocomo serializable." En D:\ Dev\Insuranse高级服务\ IAS\packages\EntityFramework.6.0.0\tools\EntityFramework.psm1:611Carácter:20 + $ domain.SetData <<<<('startUpProject',$ startUpProject)+ CategoryInfo: NotSpecified:(:) [],MethodInvocationException + FullyQualifiedErrorId:DotNetMethodException System.NullReferenceException:Referencia a objeto no establecida como instancia de un objeto.zh_cn System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project,Int32 shellVersion)zh_cn System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebProject(Project project)zh_cn System.Data.Entity.Migrations.MigrationsDomainCommand. GetFacade(String …

entity-framework

3
推荐指数
1
解决办法
918
查看次数

EF 6基于代码的迁移:向现有实体添加非null属性

我想在现有表中添加一个非null,foreing键列.

环境:EF 6,代码优先,基于代码的迁移

//Code from Migration class for new entity Currency
CreateTable("dbo.Currency",
                c => new
                    {
                        CurrencyID = c.Int(nullable: false, identity: true),
                        Code = c.String(nullable: false, maxLength: 3, fixedLength: true, unicode: false),
                        Denomination = c.String(nullable: false, maxLength: 50, unicode: false),
                    })
                .PrimaryKey(t => t.CurrencyID);

AddColumn("dbo.Collection", "CurrencyID", c => c.Int(nullable: false));

//Code from Seed() method in Configuration class 
context.Currencies.AddOrUpdate(
    new Currency
    {
        Code = "USD",
        Denomination = "Dollar"
    }
);

//Here i get an exception. Collection is the existing table
context.Database.ExecuteSqlCommand( …
Run Code Online (Sandbox Code Playgroud)

entity-framework ef-code-first ef-migrations

3
推荐指数
1
解决办法
1635
查看次数

如何在合并复制中跳过架构更改

如何在合并复制中跳过架构更改?

我向表中添加了一个非空的列,但订阅者首先必须创建具有空数据的列,因此无法复制.我已经将原始列中的此列更改为null,但代理希望首先同步第一个更改.

建议吗?

sql-server replication merge-replication sql-server-2012

3
推荐指数
1
解决办法
979
查看次数

接受按钮中的命令参数到 DelegateCommand 中

我有一个项目控件,我向其传递可观察的对象集合并将元素显示为按钮。我正在使用 DelegateCommands 捕获视图模型中的按钮单击。

我想知道如何知道单击了哪个按钮。我希望能够将与按钮关联的对象传递给我的虚拟机。

我的xaml:

<ItemsControl x:Name="list" ItemsSource="{Binding ChemList}"> //ChemList is observable collection of objects
    <ItemsControl.ItemTemplate>
        <DataTemplate>
             <Button Margin="5" 
                     Command="{Binding ElementName=list,Path=DataContext.OnBtnSelect}"
                     CommandParameter="{Binding}">
                <Button.Content>
                   <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding name}"/>
                        <TextBlock Text="    "/>
                        <TextBlock Text="{Binding num}"/>
                   </StackPanel>
                </Button.Content>
            </Button>
        </DataTemplate>
   </ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)

我的视图模型:

public DelegateCommand OnBtnSelect { get; private set; }


In the constructor:
OnBtnSelect = new DelegateCommand(OnSelect);


public void OnSelect()
{
      //How do i get here the object associated with the clicked button? 
}
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml prism visual-studio-2015

3
推荐指数
1
解决办法
3928
查看次数

jQuery验证:表单总是有效的问题

我正在尝试在提交到服务器之前进行表单验证.我正在使用jquery.validate插件(JQuery验证插件页面)我面临的问题是,无论我在表单字段中键入什么,验证总是成功,我双重检查所有内容对文档和样本通过电线,不知道为什么我得到这种行为.这个表单是通过jquery ajax加载的:

$.ajax({
    url: "mypage.php",
    type: "POST",
    cache: false,
    success: function(cont){
        $("body").append(cont);
    }
});
Run Code Online (Sandbox Code Playgroud)

在这里,我向您展示mypage.php代码

<script src="js/jquery.validate.min.js"></script>
<script type="text/javascript">

$(document).ready(function () {

    $("#frmParticipante").validate({
        rules: { 
            nombre: {  required: true  } ,
            email: { required: true, email: true },
            ci: { required: true}
        }
    });

    $("#frmParticipante").submit(function(e){
        e.preventDefault();  
        if($(this).valid()){
            loadpop("ganaste.php");
        }
    else
        loadpop("perdiste.php");    

    });
});


</script>

<div id="pop_terminaste" class="pop_mensaje ingresardatos animated fadeInDown">
    <div id="infopop">
        <div id="lady"> <img src="images/terminaste1.jpg" width="453" height="626" /> </div>
        <div id="dato">
            <p class="txt1">¡Terminaste la trivia!</p>
            <p class="txt2">Ahora …
Run Code Online (Sandbox Code Playgroud)

javascript php validation ajax jquery

2
推荐指数
1
解决办法
3065
查看次数