简体   繁体   中英

Write data to two SQL databases from Entity Framework in c#

I am having an issue with my website(ASP.NET, c#, SQL, Code-first Entity Framework).

I have a project with an attached SQL database generated from code first entity framework.

Now I have imported another SQL database using model first database which looks almost same but the table and column names are different.

So now I would like to write data to two databases at the same time with just one click from my web application.

The newly attached database will be a backup and we should write data to both databases at the same time.

Any suggestions would be highly appreciated.

Thanks

正如其他人所建议的那样,您需要自己进行映射,但是我想添加一件事,您可能需要将SaveChanges()包装到事务中,您可以在此处找到步骤: https : //msdn.microsoft.com /en-us/data/dn456843.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM