Nim*_*imp 7 c# wpf entity-framework
我已经创建了一个WPF应用程序,它首先在LocalDb上使用实体框架/代码(我已经在"模型"目录上创建了我的数据库,一切似乎都很好).
它在我的笔记本电脑上工作得很好,我想与我的朋友分享,但它不起作用.我想我在另一台计算机上有一个SQL错误,但它没有显示它.它只是显示一个Windows应用程序错误...我认为这是我尝试加载我的数据库上下文.
我的数据库环境:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
namespace ModernUINavigationApp1.Model
{
class Supcontext : DbContext
{
public DbSet<InfosConnexion> InfosConnexions { get; set; }
public DbSet<InfosFichiers> InfosFiles { get; set; }
public DbSet<Log> Logs { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我的app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Run Code Online (Sandbox Code Playgroud)
编辑:
安装了localDb,我可以在每台计算机上构建并运行一个新的实体框架解决方案,并查看服务器资源管理器上的localdb(在visual studio上).在我的解决方案(我试图共享的那个)和另一台计算机上,我删除了app.config,删除并重新导入实体框架,并在控制台上启用迁移和更新数据库然后它可以工作,但它是我认为不是正确/更好的解决方案.
我找到了解决方案:如果从其他计算机打开已经存在的实体框架(和localdb)的Visual Studio解决方案,则必须通过右键单击解决方案从该解决方案中删除实体框架(在visual studio中的解决方案资源管理器上) ),选择数据包管理器,删除实体框架并再次安装(也在数据包管理器中).它将使用正确的行配置生成一个新的app.config,它应该可以工作!
如果您从另一台计算机打开带有实体框架(和 localdb)的现有 Visual Studio 解决方案,则必须通过以下方式从此解决方案中删除实体框架:
这将生成一个app.config具有正确线路配置的新线路,并且它应该可以工作。
此答案是由 OP Nimp根据 CC BY-SA 3.0 发布的,作为对问题My WPF/EntityFramework application don't work on other computer do not work on other computer 的编辑。
| 归档时间: |
|
| 查看次数: |
1203 次 |
| 最近记录: |