So, I'm playing around with winforms (Sad to say it's my first non-console based interactable thing I've programmed). Am I correct in understanding that if I don't keep long running processes in their own threads, I'm locking up the app UI?
@Sippy White Girl Wasted To be extremely drunk, high or a mixture of both. The term is derived from the extreme inebriation most commonly experienced by white females between age 17 to 27.
is it possible in EF code first to use an existing database, add new entities, and have those entities be related to old entities? Or am I gonna have to sql it up and do database first / vanilla ado.net
@Jakotheshadows - If you manually construct the database structure and in code classes, it is very easy (that is the route I take). It isn't common though, most people don't like hand coding that stuff.
@Jakotheshadows what i did in the past was create a code-first database using migrations, and work your way to an identical schema with the original database. then copy the migrations table over, and you're done.
sql: insert table some fields someid, quantity, date
c#:
public class Some
{
[Key]
public int SomeId { get; set; }
public double Quantity { get; set; }
public DateTime Date { get; set; }
}
@TravisJ what if I don't have a code first definition for the existing database? can I start with database first and proceed with code-first to add entities?
Yeah, I think they got tired of overengineering it at some point
because they made it extensible
they're just like "ok we're done, if they want more they'll write it themselves"
I wish more software products were like that
so if I only need a handful of the tables, I can manually code those out and map them to existing tables in the database and make new entities along side them without nuking anything already existing in the table?
So.... EF uses reflection to parse your class definition to write SQL with. EF does not care about your class definition nor the table definition. The issue is with the SQL executing on the db server. If the fields exist, then there will be no problems running the SQL, even if you left out fields or tables. In other words, you can create a class that only has two rows, even if a table has 20 rows, and use only that to query with if you were so inclined.
@TravisJ I think I'm screwing my words up a lot here, and I apologize. What I mean to ask is if code first can create new tables on an existing database for entity classes that don't already have tables associated with them, as well as map the entities that do have associated tables to those tables. I'm sure I'll have to do something to make the "map to existing" thing work, but before I dive into that google-hole It'd be cool to at least know that my fantasy is possible
I think I'm gonna take the safer route and just make the tables in t-sql, and use ADO.NET to connect and serialize the data into classes in my very own data layer then