 and I'm here hey there we go hello Carlos hello from Brazil yeah all right our first South American speaker yes thank you for this all righty and I will go to your screen oh we need you to close your window up in the top right where we can see that yeah if you can excellent uh not that the yes there you go all righty okay the conference is okay okay thank you hello my name is Carlos do sense I'm CTO from cds software uh Brazilian company and today we are talking why you should create your next library using dotnet standard and this is a great week for dotnet of course dotnet core 3 was launched but if I'm working with dotnet 4 4.5 4.6 and I can't upgrade all of my code to dotnet core and I have many dependencies I already run the dotnet portability analyzer and there are many parts of my code that are incompatible with dotnet core and I have a problem with this how can I use the benefits of dotnet core dotnet core has many many benefits the velocity the facilities and for you you have I have some options you can rewrite all of your core code but it's impossible in many cases because maybe you have a very big application or legacy code and the application in production is that is not viable change this code you can't forget every innovations and continue with the same okay dotnet core is cool but it's not for me and uh you can create the only new projects using dotnet core it's an approach for many companies because I have a big legacy and I focus on create some new things using dotnet core only this but if you could move some parts of your code to dotnet core what do you think about this and do you know dotnet standard dotnet standard it's present in all of frameworks and uh it's uh for me it's a way to create a standard implementation between frameworks this means that I can create code that's running dotnet framework dotnet core and xamar of course and I have here uh dotnet standard compatibility table and now we are here we have dotnet core 3 and dotnet standard 2.1 in prevail and if you look the left side I have dotnet standard 2 dotnet core 2 and dotnet framework 4.6.1 and this is great because I can write the code that run between these platforms and your choice is dotnet standard because you can move some parts of your code to a standard library and then if you have a business logic you can move this part of your code that maybe is not not to have problem with portability to a standard library and use and both frameworks and choosing this you can use the benefits of dotnet core in your legacy application and better than this you are improving your code your codes you are moving forward and now you can write some code using dotnet core working together your with your legacy code and this is great and dotnet standard 2.1 that is present in dotnet core is not compatible with dotnet framework but the version 2.0 of dotnet standard is this and you can reference projects that you can use that you create using dotnet standard 2 in dotnet core 3 and dotnet framework it seems confusing right but it's not I have a demo to explain this how can I use dotnet standard in my legacy code first you need to move the dotnet framework version of your current project to 4.6.1 at least I recommend you move to the last version today the 4.7.2 it's the first it's not very complicated because you are improving your code because you are using a newer version of dotnet framework it's very common companies has dotnet 4 or 4.5 in your code and you can move to a new version and solve some maybe problems with compatibility it's not very complicated to do second you can move some classes or parts of your code or for example a business layer or data access that is compatible with dotnet core and you can use the portability analyzer 2 that is present on visual studio and test this code and move it to a dotnet standard 2 project and then you can extract parts of your code or maybe you have a do you have a library you can move it to dotnet standard project okay and finally you can reference the dotnet core libraries in your dotnet framework project and I have a for example I have a dotnet full dotnet framework project and I have a dotnet standard library that can I use in this project dotnet full and a dotnet core project and it's great too if you have dotnet core projects of course you can reference the same library as well and writing your libraries in dotnet standard writing your libraries you can use the benefits of dotnet core and principally you create better code and improve your developers capabilities this is great because maybe you have developers that can use the new technology because you have a legacy code and this is frustrating because developers can work every day with a node code and a node tools and using this approach you can move in increasing capabilities of your developers and your developers has a chance to learn new things and new frameworks and using new functions of dotnet core and improve your performance and improve your code and you keep your legacy code running that is very important because you can move all of your code maybe to dotnet core and you'll have the better of two words now and prepare your company to the future because you are using a new version of tools and remember that the dotnet 4.8 is the last version of the full framework now the word is dotnet core okay i have a demo for you and i will i'm using here the visual studio 19 and i have here a very simple solution that has four projects i have a some consult application that is it's the proposal only to show this this combination of core and full framework and i have a console core console full i have a library core in standard and i have a thing that is entity framework core in a library and uh if i looking for this library and i click here it's a dotnet standard library it's only this and you can create a new library using dotnet standard or you can pick up your current codes and convert to a dotnet a dotnet standard dotnet core project using dotnet standard two this is very important here that's two compatible with dotnet framework i needed to use dotnet standard two not 2.1 because 2.1 is only for dotnet core three right okay and on this project i have a customer class is very simple and i have a customer server that's a simple two and i have a list of customer here but is running on dotnet core and i have here a console full that is a dotnet framework application that use dotnet framework 4.7.2 okay it's a here it's a console application but you can use every kind of application right and i have here oh i will close here and i will show a console application and i have here it's it's pretty simple i have a console here that has a new object based on my customer servers that is a code that is inside my core standard library it's here and i mean i have here two kinds of projects i will run this i will comment this part first because it's another library and i will run it's very simple okay this is to this compiling okay it's very very simple here i have dotnet core a dotnet full framework application here i have dotnet standard and then i have the two things running together right and i have another library here that it's a entity framework core oh this is very interesting because uh if you if you can use the new entity framework core it is better better than the last version that you entered framework 6 and you have many control you have many more performance about your code and it's a very good ORM platform for you and if you need if you want to use this platform you can create this approach this kind of classes i have a classes here that is another standard library and i have here only something different because i need to copy entity framework assemblies to my my principal project and i have here an entity framework core 2.2 but why you don't don't have entity framework core 3 because i'm in a dotnet standard 2 and i can't use in the dotnet standard 2 entity framework core 3 because it's using dotnet standard 2.1 but it's okay it's a very good version of dotnet core of entity framework core and i have here the entity framework core and the SQL server core and it's a very simple i have here the context class and i have here my my connection string is not a better approach but it's on for demo purpose and i have here a context the simple context i have a customer here i'm using the the femmels north wind database and i have a service here it's a customer service here that it has a context and i create a context and i get all customers it's pretty simple right and i go back to my console app and i uncomment here and i have here an instance of customer service ef and i have here all of customers reading for ef right it's very simple here i have entity framework core running inside a dotnet full framework application right and i have another project here it's simple too it's a console core and how i said i can use the same library and buff project but this project is a dotnet core app 3 oh of course i can use a dotnet core app 2 or 2.2 it's not a problem and i have a reference here for my libraries and i have the same code here it's very simple i have here the same code using the same libraries because dotnet standard is compatible with all of frameworks i can use this i can run and i have the same code here it's a pretty simple code i have the same the same code running and both platforms and my message for you is you can move your coding forward even you have a legacy code and this is a very simple application but you can see the potential of this kind of code i can use the same code both and two frameworks okay and there is it's a very simple explanation about the dotnet standard and how can you use this on your application and i will return to my deck here and i have some links for you for example oh i have questions about dotnet standard i can't understand these and how can this works you have a great documentation from microsoft about dotnet standard and dotnet standard 2.2.1 and how this working after this or after dotnet core 3 and remember you need to move your coding forward you need to improve your legacy code and there is thank you for watching this presentation and i hope that you can move your code to dotnet core oh this code was i will put this code on my github repo for people that can see you oh that's great carlos thank you so much yes we love to have that that code available in the github repos yes thank you for this opportunity thank you very much thank you and uh we we know our friends