简体   繁体   English

EF-从数据库导入新表并使其替换现有表

[英]EF - Import a new table from DB and have it replace an existing one

So I need to update the model from the db. 因此,我需要从数据库更新模型。 The issue is that I want the new table to replace an existing one. 问题是我希望新表替换现有表。

This is the format of my existing table. 这是我现有表格的格式。

原始表

Here is the new table after import it from the DB. 这是从数据库导入后的新表。

新表

I delete the original table and rename the fields to match, build and get errors. 我删除了原始表,并重命名了字段以匹配,构建和获取错误。 I am getting errors because it can't find UserProfileTenant. 我收到错误消息,因为找不到UserProfileTenant。 When I use intellisense I see that it has USR_PROFILE_TENANT2 instead of UserProfileTenant. 当我使用智能感知时,我看到它具有USR_PROFILE_TENANT2而不是UserProfileTenant。

I'm not sure where I need to update to have names properly updated. 我不确定要在何处正确更新名称。

Looking through some questions I found Change DB in EF . 通过一些问题,我发现了EF中的Change DB But the accepted answer isn't the one I used. 但是接受的答案不是我使用的答案。 Its this one by zeeshanhirani . 它的这一个zeeshanhirani

Besure to also update the column mappings after the new table is selected. 选择新表后,还要确保也更新列映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EF和现有数据库和表,以及一堆新表 - EF and existing database and table, with a bunch of new tables 在不丢失现有数据的情况下向现有EF模型添加新表 - Adding a new table to an existing EF model without losing existing data EF Core 无法将数据从旧数据库传输到新 SQL Server 数据库中 - EF Core Fails to transfer data into new SQL Server DB from old one 在数据库中创建一个新表以从一个已经存在的大表中提取数据 - Make a new table in DB to extract data from an already existing large table 使用数据库第一种方法EF将新表添加到现有数据库 - Add new table to an existing database using database first approach EF 首先使用匹配现有类创建新表EF代码 - Create New Table EF Code First with Match existing class EF Table-Per-Type:将新的子代添加到现有父代 - EF Table-Per-Type: Add new child to an existing parent 如何使用EF 4.4和现有DB从POCO更新数据库? - How to update database from POCO using EF 4.4 with existing DB? 如何用 Visual Studio 解决方案/项目中的新 GUID 替换所有现有的 GUID? - How to replace all the existing GUIDs with new one from the Visual Studio solution/project? EF。 根据第二个表中记录的属性从一个表中选择记录,而第二个表中记录的属性为FK - EF. Select records from one table based on the properties of the records from second table that have an FK from the first
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM