Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Using EntityFrameworkCore with an existing database

$
0
0

I am building a new application that will connect to an existing database. I have used the reverse engineering tool and it all works OK. However I wopuld like to give my entitles and model properties more meaningful names

I tried the following in the OnModelCreating function

builder.Entity<Donor>().ToTable("personal");
builder.Entity<Donor>().Property(d => d.Id).HasColumnName("p_key");
builder.Entity<Donor>().Property(d => d.Title).HasColumnName("p_title");
builder.Entity<Donor>().Property(d => d.Surname).HasColumnName("p_surname");

However when I update the database I get  the error There is already an object named 'personal' in the database. 

I have tried to find a way of doing this andI can see that you could change the mappings with the designer in the previous version.

Any help would be much appreciated.

Thanks


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>